<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
	<title>API: connection   connection.js  (YUI Library)</title>
	<link rel="stylesheet" type="text/css" href="assets/api.css">
</head>

<body id="yahoo-com">
<div id="doc3" class="yui-t2">

	<div id="hd">
        <h1>Yahoo! UI Library</h1>
        <h3>connection&nbsp; <span class="subtitle">2.2.2</span></h3>
        <p>
        <a href="./index.html">Yahoo! UI Library</a> 
            &gt; <a href="./module_connection.html">connection</a>
                
                 &gt; connection.js (source view) 
            </p>
	</div>

	<div id="bd">
		<div id="yui-main">
			<div class="yui-b">

                    <div id="srcout">
<div class="highlight" ><pre><span class="c">/**</span>
<span class="c"> * The Connection Manager provides a simplified interface to the XMLHttpRequest</span>
<span class="c"> * object.  It handles cross-browser instantiantion of XMLHttpRequest, negotiates the</span>
<span class="c"> * interactive states and server response, returning the results to a pre-defined</span>
<span class="c"> * callback you create.</span>
<span class="c"> *</span>
<span class="c"> * @namespace YAHOO.util</span>
<span class="c"> * @module connection</span>
<span class="c"> * @requires yahoo</span>
<span class="c"> */</span>

<span class="c">/**</span>
<span class="c"> * The Connection Manager singleton provides methods for creating and managing</span>
<span class="c"> * asynchronous transactions.</span>
<span class="c"> *</span>
<span class="c"> * @class Connect</span>
<span class="c"> */</span>

<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Connect</span> <span class="o">=</span>
<span class="o">{</span>
  <span class="c">/**</span>
<span class="c">   * @description Array of MSFT ActiveX ids for XMLHttpRequest.</span>
<span class="c">   * @property _msxml_progid</span>
<span class="c">   * @private</span>
<span class="c">   * @static</span>
<span class="c">   * @type array</span>
<span class="c">   */</span>
	<span class="nx">_msxml_progid</span><span class="o">:[</span>
		<span class="s1">&#39;MSXML2.XMLHTTP.3.0&#39;</span><span class="o">,</span>
		<span class="s1">&#39;MSXML2.XMLHTTP&#39;</span><span class="o">,</span>
		<span class="s1">&#39;Microsoft.XMLHTTP&#39;</span>
		<span class="o">],</span>

  <span class="c">/**</span>
<span class="c">   * @description Object literal of HTTP header(s)</span>
<span class="c">   * @property _http_header</span>
<span class="c">   * @private</span>
<span class="c">   * @static</span>
<span class="c">   * @type object</span>
<span class="c">   */</span>
	<span class="nx">_http_headers</span><span class="o">:{},</span>

  <span class="c">/**</span>
<span class="c">   * @description Determines if HTTP headers are set.</span>
<span class="c">   * @property _has_http_headers</span>
<span class="c">   * @private</span>
<span class="c">   * @static</span>
<span class="c">   * @type boolean</span>
<span class="c">   */</span>
	<span class="nx">_has_http_headers</span><span class="o">:</span><span class="kc">false</span><span class="o">,</span>

 <span class="c">/**</span>
<span class="c">  * @description Determines if a default header of</span>
<span class="c">  * Content-Type of &#39;application/x-www-form-urlencoded&#39;</span>
<span class="c">  * will be added to any client HTTP headers sent for POST</span>
<span class="c">  * transactions.</span>
<span class="c">  * @property _use_default_post_header</span>
<span class="c">  * @private</span>
<span class="c">  * @static</span>
<span class="c">  * @type boolean</span>
<span class="c">  */</span>
    <span class="nx">_use_default_post_header</span><span class="o">:</span><span class="kc">true</span><span class="o">,</span>

 <span class="c">/**</span>
<span class="c">  * @description Determines if a default header of</span>
<span class="c">  * Content-Type of &#39;application/x-www-form-urlencoded&#39;</span>
<span class="c">  * will be added to client HTTP headers sent for POST</span>
<span class="c">  * transactions.</span>
<span class="c">  * @property _default_post_header</span>
<span class="c">  * @private</span>
<span class="c">  * @static</span>
<span class="c">  * @type boolean</span>
<span class="c">  */</span>
    <span class="nx">_default_post_header</span><span class="o">:</span><span class="s1">&#39;application/x-www-form-urlencoded; charset=UTF-8&#39;</span><span class="o">,</span>

 <span class="c">/**</span>
<span class="c">  * @description Determines if a default header of</span>
<span class="c">  * &#39;X-Requested-With: XMLHttpRequest&#39;</span>
<span class="c">  * will be added to each transaction.</span>
<span class="c">  * @property _use_default_xhr_header</span>
<span class="c">  * @private</span>
<span class="c">  * @static</span>
<span class="c">  * @type boolean</span>
<span class="c">  */</span>
    <span class="nx">_use_default_xhr_header</span><span class="o">:</span><span class="kc">true</span><span class="o">,</span>

 <span class="c">/**</span>
<span class="c">  * @description The default header value for the label</span>
<span class="c">  * &quot;X-Requested-With&quot;.  This is sent with each</span>
<span class="c">  * transaction, by default, to identify the</span>
<span class="c">  * request as being made by YUI Connection Manager.</span>
<span class="c">  * @property _default_xhr_header</span>
<span class="c">  * @private</span>
<span class="c">  * @static</span>
<span class="c">  * @type boolean</span>
<span class="c">  */</span>
    <span class="nx">_default_xhr_header</span><span class="o">:</span><span class="s1">&#39;XMLHttpRequest&#39;</span><span class="o">,</span>

 <span class="c">/**</span>
<span class="c">  * @description Determines if custom, default headers</span>
<span class="c">  * are set for each transaction.</span>
<span class="c">  * @property _has_default_header</span>
<span class="c">  * @private</span>
<span class="c">  * @static</span>
<span class="c">  * @type boolean</span>
<span class="c">  */</span>
    <span class="nx">_has_default_headers</span><span class="o">:</span><span class="kc">true</span><span class="o">,</span>

 <span class="c">/**</span>
<span class="c">  * @description Determines if custom, default headers</span>
<span class="c">  * are set for each transaction.</span>
<span class="c">  * @property _has_default_header</span>
<span class="c">  * @private</span>
<span class="c">  * @static</span>
<span class="c">  * @type boolean</span>
<span class="c">  */</span>
    <span class="nx">_default_headers</span><span class="o">:{},</span>

 <span class="c">/**</span>
<span class="c">  * @description Property modified by setForm() to determine if the data</span>
<span class="c">  * should be submitted as an HTML form.</span>
<span class="c">  * @property _isFormSubmit</span>
<span class="c">  * @private</span>
<span class="c">  * @static</span>
<span class="c">  * @type boolean</span>
<span class="c">  */</span>
    <span class="nx">_isFormSubmit</span><span class="o">:</span><span class="kc">false</span><span class="o">,</span>

 <span class="c">/**</span>
<span class="c">  * @description Property modified by setForm() to determine if a file(s)</span>
<span class="c">  * upload is expected.</span>
<span class="c">  * @property _isFileUpload</span>
<span class="c">  * @private</span>
<span class="c">  * @static</span>
<span class="c">  * @type boolean</span>
<span class="c">  */</span>
    <span class="nx">_isFileUpload</span><span class="o">:</span><span class="kc">false</span><span class="o">,</span>

 <span class="c">/**</span>
<span class="c">  * @description Property modified by setForm() to set a reference to the HTML</span>
<span class="c">  * form node if the desired action is file upload.</span>
<span class="c">  * @property _formNode</span>
<span class="c">  * @private</span>
<span class="c">  * @static</span>
<span class="c">  * @type object</span>
<span class="c">  */</span>
    <span class="nx">_formNode</span><span class="o">:</span><span class="kc">null</span><span class="o">,</span>

 <span class="c">/**</span>
<span class="c">  * @description Property modified by setForm() to set the HTML form data</span>
<span class="c">  * for each transaction.</span>
<span class="c">  * @property _sFormData</span>
<span class="c">  * @private</span>
<span class="c">  * @static</span>
<span class="c">  * @type string</span>
<span class="c">  */</span>
    <span class="nx">_sFormData</span><span class="o">:</span><span class="kc">null</span><span class="o">,</span>

 <span class="c">/**</span>
<span class="c">  * @description Collection of polling references to the polling mechanism in handleReadyState.</span>
<span class="c">  * @property _poll</span>
<span class="c">  * @private</span>
<span class="c">  * @static</span>
<span class="c">  * @type object</span>
<span class="c">  */</span>
    <span class="nx">_poll</span><span class="o">:{},</span>

 <span class="c">/**</span>
<span class="c">  * @description Queue of timeout values for each transaction callback with a defined timeout value.</span>
<span class="c">  * @property _timeOut</span>
<span class="c">  * @private</span>
<span class="c">  * @static</span>
<span class="c">  * @type object</span>
<span class="c">  */</span>
    <span class="nx">_timeOut</span><span class="o">:{},</span>

  <span class="c">/**</span>
<span class="c">   * @description The polling frequency, in milliseconds, for HandleReadyState.</span>
<span class="c">   * when attempting to determine a transaction&#39;s XHR readyState.</span>
<span class="c">   * The default is 50 milliseconds.</span>
<span class="c">   * @property _polling_interval</span>
<span class="c">   * @private</span>
<span class="c">   * @static</span>
<span class="c">   * @type int</span>
<span class="c">   */</span>
     <span class="nx">_polling_interval</span><span class="o">:</span><span class="m">50</span><span class="o">,</span>

  <span class="c">/**</span>
<span class="c">   * @description A transaction counter that increments the transaction id for each transaction.</span>
<span class="c">   * @property _transaction_id</span>
<span class="c">   * @private</span>
<span class="c">   * @static</span>
<span class="c">   * @type int</span>
<span class="c">   */</span>
     <span class="nx">_transaction_id</span><span class="o">:</span><span class="m">0</span><span class="o">,</span>

  <span class="c">/**</span>
<span class="c">   * @description Tracks the name-value pair of the &quot;clicked&quot; submit button if multiple submit</span>
<span class="c">   * buttons are present in an HTML form; and, if YAHOO.util.Event is available.</span>
<span class="c">   * @property _submitElementValue</span>
<span class="c">   * @private</span>
<span class="c">   * @static</span>
<span class="c">   * @type string</span>
<span class="c">   */</span>
	 <span class="nx">_submitElementValue</span><span class="o">:</span><span class="kc">null</span><span class="o">,</span>

  <span class="c">/**</span>
<span class="c">   * @description Determines whether YAHOO.util.Event is available and returns true or false.</span>
<span class="c">   * If true, an event listener is bound at the document level to trap click events that</span>
<span class="c">   * resolve to a target type of &quot;Submit&quot;.  This listener will enable setForm() to determine</span>
<span class="c">   * the clicked &quot;Submit&quot; value in a multi-Submit button, HTML form.</span>
<span class="c">   * @property _hasSubmitListener</span>
<span class="c">   * @private</span>
<span class="c">   * @static</span>
<span class="c">   * @type boolean</span>
<span class="c">   */</span>
	 <span class="nx">_hasSubmitListener</span><span class="o">:(</span><span class="k">function</span><span class="o">()</span>
	 <span class="o">{</span>
		<span class="k">if</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">){</span>
			<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">addListener</span><span class="o">(</span>
				<span class="nb">document</span><span class="o">,</span>
				<span class="s1">&#39;click&#39;</span><span class="o">,</span>
				<span class="k">function</span><span class="o">(</span><span class="nx">e</span><span class="o">){</span>
					<span class="k">var</span> <span class="nx">obj</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">getTarget</span><span class="o">(</span><span class="nx">e</span><span class="o">);</span>
					<span class="k">if</span><span class="o">(</span><span class="nx">obj</span><span class="o">.</span><span class="nx">type</span> <span class="o">==</span> <span class="s1">&#39;submit&#39;</span><span class="o">){</span>
						<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Connect</span><span class="o">.</span><span class="nx">_submitElementValue</span> <span class="o">=</span> <span class="nb">encodeURIComponent</span><span class="o">(</span><span class="nx">obj</span><span class="o">.</span><span class="nx">name</span><span class="o">)</span> <span class="o">+</span> <span class="s2">&quot;=&quot;</span> <span class="o">+</span> <span class="nb">encodeURIComponent</span><span class="o">(</span><span class="nx">obj</span><span class="o">.</span><span class="nx">value</span><span class="o">);</span>
					<span class="o">}</span>
				<span class="o">})</span>
			<span class="k">return</span> <span class="kc">true</span><span class="o">;</span>
	    <span class="o">}</span>
	    <span class="k">return</span> <span class="kc">false</span><span class="o">;</span>
	 <span class="o">})(),</span>

  <span class="c">/**</span>
<span class="c">   * @description Member to add an ActiveX id to the existing xml_progid array.</span>
<span class="c">   * In the event(unlikely) a new ActiveX id is introduced, it can be added</span>
<span class="c">   * without internal code modifications.</span>
<span class="c">   * @method setProgId</span>
<span class="c">   * @public</span>
<span class="c">   * @static</span>
<span class="c">   * @param {string} id The ActiveX id to be added to initialize the XHR object.</span>
<span class="c">   * @return void</span>
<span class="c">   */</span>
	<span class="nx">setProgId</span><span class="o">:</span><span class="k">function</span><span class="o">(</span><span class="nx">id</span><span class="o">)</span>
	<span class="o">{</span>
		<span class="k">this</span><span class="o">.</span><span class="nx">_msxml_progid</span><span class="o">.</span><span class="nx">unshift</span><span class="o">(</span><span class="nx">id</span><span class="o">);</span>
		<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">&#39;ActiveX Program Id  &#39;</span> <span class="o">+</span> <span class="nx">id</span> <span class="o">+</span> <span class="s1">&#39; added to _msxml_progid.&#39;</span><span class="o">,</span> <span class="s1">&#39;info&#39;</span><span class="o">,</span> <span class="s1">&#39;Connection&#39;</span><span class="o">);</span>
	<span class="o">},</span>

  <span class="c">/**</span>
<span class="c">   * @description Member to enable or disable the default POST header.</span>
<span class="c">   * @method setDefaultPostHeader</span>
<span class="c">   * @public</span>
<span class="c">   * @static</span>
<span class="c">   * @param {boolean} b Set and use default header - true or false .</span>
<span class="c">   * @return void</span>
<span class="c">   */</span>
	<span class="nx">setDefaultPostHeader</span><span class="o">:</span><span class="k">function</span><span class="o">(</span><span class="nx">b</span><span class="o">)</span>
	<span class="o">{</span>
		<span class="k">this</span><span class="o">.</span><span class="nx">_use_default_post_header</span> <span class="o">=</span> <span class="nx">b</span><span class="o">;</span>
		<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">&#39;Use default POST header set to  &#39;</span> <span class="o">+</span> <span class="nx">b</span><span class="o">,</span> <span class="s1">&#39;info&#39;</span><span class="o">,</span> <span class="s1">&#39;Connection&#39;</span><span class="o">);</span>
	<span class="o">},</span>

  <span class="c">/**</span>
<span class="c">   * @description Member to enable or disable the default POST header.</span>
<span class="c">   * @method setDefaultXhrHeader</span>
<span class="c">   * @public</span>
<span class="c">   * @static</span>
<span class="c">   * @param {boolean} b Set and use default header - true or false .</span>
<span class="c">   * @return void</span>
<span class="c">   */</span>
	<span class="nx">setDefaultXhrHeader</span><span class="o">:</span><span class="k">function</span><span class="o">(</span><span class="nx">b</span><span class="o">)</span>
	<span class="o">{</span>
		<span class="k">this</span><span class="o">.</span><span class="nx">_use_default_xhr_header</span> <span class="o">=</span> <span class="nx">b</span><span class="o">;</span>
		<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">&#39;Use default transaction header set to  &#39;</span> <span class="o">+</span> <span class="nx">b</span><span class="o">,</span> <span class="s1">&#39;info&#39;</span><span class="o">,</span> <span class="s1">&#39;Connection&#39;</span><span class="o">);</span>
	<span class="o">},</span>

  <span class="c">/**</span>
<span class="c">   * @description Member to modify the default polling interval.</span>
<span class="c">   * @method setPollingInterval</span>
<span class="c">   * @public</span>
<span class="c">   * @static</span>
<span class="c">   * @param {int} i The polling interval in milliseconds.</span>
<span class="c">   * @return void</span>
<span class="c">   */</span>
	<span class="nx">setPollingInterval</span><span class="o">:</span><span class="k">function</span><span class="o">(</span><span class="nx">i</span><span class="o">)</span>
	<span class="o">{</span>
		<span class="k">if</span><span class="o">(</span><span class="k">typeof</span> <span class="nx">i</span> <span class="o">==</span> <span class="s1">&#39;number&#39;</span> <span class="o">&amp;&amp;</span> <span class="nb">isFinite</span><span class="o">(</span><span class="nx">i</span><span class="o">)){</span>
			<span class="k">this</span><span class="o">.</span><span class="nx">_polling_interval</span> <span class="o">=</span> <span class="nx">i</span><span class="o">;</span>
			<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">&#39;Default polling interval set to &#39;</span> <span class="o">+</span> <span class="nx">i</span> <span class="o">+</span><span class="s1">&#39;ms&#39;</span><span class="o">,</span> <span class="s1">&#39;info&#39;</span><span class="o">,</span> <span class="s1">&#39;Connection&#39;</span><span class="o">);</span>
		<span class="o">}</span>
	<span class="o">},</span>

  <span class="c">/**</span>
<span class="c">   * @description Instantiates a XMLHttpRequest object and returns an object with two properties:</span>
<span class="c">   * the XMLHttpRequest instance and the transaction id.</span>
<span class="c">   * @method createXhrObject</span>
<span class="c">   * @private</span>
<span class="c">   * @static</span>
<span class="c">   * @param {int} transactionId Property containing the transaction id for this transaction.</span>
<span class="c">   * @return object</span>
<span class="c">   */</span>
	<span class="nx">createXhrObject</span><span class="o">:</span><span class="k">function</span><span class="o">(</span><span class="nx">transactionId</span><span class="o">)</span>
	<span class="o">{</span>
		<span class="k">var</span> <span class="nx">obj</span><span class="o">,</span><span class="nx">http</span><span class="o">;</span>
		<span class="k">try</span>
		<span class="o">{</span>
			<span class="c">// Instantiates XMLHttpRequest in non-IE browsers and assigns to http.</span>
<span class="c"></span>			<span class="nx">http</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">XMLHttpRequest</span><span class="o">();</span>
			<span class="c">//  Object literal with http and tId properties</span>
<span class="c"></span>			<span class="nx">obj</span> <span class="o">=</span> <span class="o">{</span> <span class="nx">conn</span><span class="o">:</span><span class="nx">http</span><span class="o">,</span> <span class="nx">tId</span><span class="o">:</span><span class="nx">transactionId</span> <span class="o">};</span>
			<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">&#39;XHR object created for transaction &#39;</span> <span class="o">+</span> <span class="nx">transactionId</span><span class="o">,</span> <span class="s1">&#39;info&#39;</span><span class="o">,</span> <span class="s1">&#39;Connection&#39;</span><span class="o">);</span>
		<span class="o">}</span>
		<span class="k">catch</span><span class="o">(</span><span class="nx">e</span><span class="o">)</span>
		<span class="o">{</span>
			<span class="k">for</span><span class="o">(</span><span class="k">var</span> <span class="nx">i</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="k">this</span><span class="o">.</span><span class="nx">_msxml_progid</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="o">++</span><span class="nx">i</span><span class="o">){</span>
				<span class="k">try</span>
				<span class="o">{</span>
					<span class="c">// Instantiates XMLHttpRequest for IE and assign to http.</span>
<span class="c"></span>					<span class="nx">http</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">ActiveXObject</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_msxml_progid</span><span class="o">[</span><span class="nx">i</span><span class="o">]);</span>
					<span class="c">//  Object literal with conn and tId properties</span>
<span class="c"></span>					<span class="nx">obj</span> <span class="o">=</span> <span class="o">{</span> <span class="nx">conn</span><span class="o">:</span><span class="nx">http</span><span class="o">,</span> <span class="nx">tId</span><span class="o">:</span><span class="nx">transactionId</span> <span class="o">};</span>
					<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">&#39;ActiveX XHR object created for transaction &#39;</span> <span class="o">+</span> <span class="nx">transactionId</span><span class="o">,</span> <span class="s1">&#39;info&#39;</span><span class="o">,</span> <span class="s1">&#39;Connection&#39;</span><span class="o">);</span>
					<span class="k">break</span><span class="o">;</span>
				<span class="o">}</span>
				<span class="k">catch</span><span class="o">(</span><span class="nx">e</span><span class="o">){}</span>
			<span class="o">}</span>
		<span class="o">}</span>
		<span class="nx">finally</span>
		<span class="o">{</span>
			<span class="k">return</span> <span class="nx">obj</span><span class="o">;</span>
		<span class="o">}</span>
	<span class="o">},</span>

  <span class="c">/**</span>
<span class="c">   * @description This method is called by asyncRequest to create a</span>
<span class="c">   * valid connection object for the transaction.  It also passes a</span>
<span class="c">   * transaction id and increments the transaction id counter.</span>
<span class="c">   * @method getConnectionObject</span>
<span class="c">   * @private</span>
<span class="c">   * @static</span>
<span class="c">   * @return {object}</span>
<span class="c">   */</span>
	<span class="nx">getConnectionObject</span><span class="o">:</span><span class="k">function</span><span class="o">()</span>
	<span class="o">{</span>
		<span class="k">var</span> <span class="nx">o</span><span class="o">;</span>
		<span class="k">var</span> <span class="nx">tId</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_transaction_id</span><span class="o">;</span>

		<span class="k">try</span>
		<span class="o">{</span>
			<span class="nx">o</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">createXhrObject</span><span class="o">(</span><span class="nx">tId</span><span class="o">);</span>
			<span class="k">if</span><span class="o">(</span><span class="nx">o</span><span class="o">){</span>
				<span class="k">this</span><span class="o">.</span><span class="nx">_transaction_id</span><span class="o">++;</span>
			<span class="o">}</span>
		<span class="o">}</span>
		<span class="k">catch</span><span class="o">(</span><span class="nx">e</span><span class="o">){}</span>
		<span class="nx">finally</span>
		<span class="o">{</span>
			<span class="k">return</span> <span class="nx">o</span><span class="o">;</span>
		<span class="o">}</span>
	<span class="o">},</span>

  <span class="c">/**</span>
<span class="c">   * @description Method for initiating an asynchronous request via the XHR object.</span>
<span class="c">   * @method asyncRequest</span>
<span class="c">   * @public</span>
<span class="c">   * @static</span>
<span class="c">   * @param {string} method HTTP transaction method</span>
<span class="c">   * @param {string} uri Fully qualified path of resource</span>
<span class="c">   * @param {callback} callback User-defined callback function or object</span>
<span class="c">   * @param {string} postData POST body</span>
<span class="c">   * @return {object} Returns the connection object</span>
<span class="c">   */</span>
	<span class="nx">asyncRequest</span><span class="o">:</span><span class="k">function</span><span class="o">(</span><span class="nx">method</span><span class="o">,</span> <span class="nx">uri</span><span class="o">,</span> <span class="nx">callback</span><span class="o">,</span> <span class="nx">postData</span><span class="o">)</span>
	<span class="o">{</span>
		<span class="k">var</span> <span class="nx">o</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getConnectionObject</span><span class="o">();</span>

		<span class="k">if</span><span class="o">(!</span><span class="nx">o</span><span class="o">){</span>
			<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">&#39;Unable to create connection object.&#39;</span><span class="o">,</span> <span class="s1">&#39;error&#39;</span><span class="o">,</span> <span class="s1">&#39;Connection&#39;</span><span class="o">);</span>
			<span class="k">return</span> <span class="kc">null</span><span class="o">;</span>
		<span class="o">}</span>
		<span class="k">else</span><span class="o">{</span>
			<span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_isFormSubmit</span><span class="o">){</span>
				<span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_isFileUpload</span><span class="o">){</span>
					<span class="k">this</span><span class="o">.</span><span class="nx">uploadFile</span><span class="o">(</span><span class="nx">o</span><span class="o">.</span><span class="nx">tId</span><span class="o">,</span> <span class="nx">callback</span><span class="o">,</span> <span class="nx">uri</span><span class="o">,</span> <span class="nx">postData</span><span class="o">);</span>
					<span class="k">this</span><span class="o">.</span><span class="nx">releaseObject</span><span class="o">(</span><span class="nx">o</span><span class="o">);</span>

					<span class="k">return</span><span class="o">;</span>
				<span class="o">}</span>

				<span class="c">//If the specified HTTP method is GET, setForm() will return an</span>
<span class="c"></span>				<span class="c">//encoded string that is concatenated to the uri to</span>
<span class="c"></span>				<span class="c">//create a querystring.</span>
<span class="c"></span>				<span class="k">if</span><span class="o">(</span><span class="nx">method</span><span class="o">.</span><span class="nx">toUpperCase</span><span class="o">()</span> <span class="o">==</span> <span class="s1">&#39;GET&#39;</span><span class="o">){</span>
					<span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_sFormData</span><span class="o">.</span><span class="nx">length</span> <span class="o">!=</span> <span class="m">0</span><span class="o">){</span>
						<span class="c">// If the URI already contains a querystring, append an ampersand</span>
<span class="c"></span>						<span class="c">// and then concatenate _sFormData to the URI.</span>
<span class="c"></span>						<span class="nx">uri</span> <span class="o">+=</span> <span class="o">((</span><span class="nx">uri</span><span class="o">.</span><span class="nx">indexOf</span><span class="o">(</span><span class="s1">&#39;?&#39;</span><span class="o">)</span> <span class="o">==</span> <span class="o">-</span><span class="m">1</span><span class="o">)?</span><span class="s1">&#39;?&#39;</span><span class="o">:</span><span class="s1">&#39;&amp;&#39;</span><span class="o">)</span> <span class="o">+</span> <span class="k">this</span><span class="o">.</span><span class="nx">_sFormData</span><span class="o">;</span>
					<span class="o">}</span>
					<span class="k">else</span><span class="o">{</span>
						<span class="nx">uri</span> <span class="o">+=</span> <span class="s2">&quot;?&quot;</span> <span class="o">+</span> <span class="k">this</span><span class="o">.</span><span class="nx">_sFormData</span><span class="o">;</span>
					<span class="o">}</span>
				<span class="o">}</span>
				<span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">method</span><span class="o">.</span><span class="nx">toUpperCase</span><span class="o">()</span> <span class="o">==</span> <span class="s1">&#39;POST&#39;</span><span class="o">){</span>
					<span class="c">//If POST data exist in addition to the HTML form data,</span>
<span class="c"></span>					<span class="c">//it will be concatenated to the form data.</span>
<span class="c"></span>					<span class="nx">postData</span> <span class="o">=</span> <span class="nx">postData</span><span class="o">?</span><span class="k">this</span><span class="o">.</span><span class="nx">_sFormData</span> <span class="o">+</span> <span class="s2">&quot;&amp;&quot;</span> <span class="o">+</span> <span class="nx">postData</span><span class="o">:</span><span class="k">this</span><span class="o">.</span><span class="nx">_sFormData</span><span class="o">;</span>
				<span class="o">}</span>
			<span class="o">}</span>

			<span class="nx">o</span><span class="o">.</span><span class="nx">conn</span><span class="o">.</span><span class="nx">open</span><span class="o">(</span><span class="nx">method</span><span class="o">,</span> <span class="nx">uri</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>

			<span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_use_default_xhr_header</span><span class="o">){</span>
				<span class="k">if</span><span class="o">(!</span><span class="k">this</span><span class="o">.</span><span class="nx">_default_headers</span><span class="o">[</span><span class="s1">&#39;X-Requested-With&#39;</span><span class="o">]){</span>
					<span class="k">this</span><span class="o">.</span><span class="nx">initHeader</span><span class="o">(</span><span class="s1">&#39;X-Requested-With&#39;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_default_xhr_header</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
					<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">&#39;Initialize transaction header X-Request-Header to XMLHttpRequest.&#39;</span><span class="o">,</span> <span class="s1">&#39;info&#39;</span><span class="o">,</span> <span class="s1">&#39;Connection&#39;</span><span class="o">);</span>
				<span class="o">}</span>
			<span class="o">}</span>
			<span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_isFormSubmit</span> <span class="o">||</span> <span class="o">(</span><span class="nx">postData</span> <span class="o">&amp;&amp;</span> <span class="k">this</span><span class="o">.</span><span class="nx">_use_default_post_header</span><span class="o">)){</span>
				<span class="k">this</span><span class="o">.</span><span class="nx">initHeader</span><span class="o">(</span><span class="s1">&#39;Content-Type&#39;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_default_post_header</span><span class="o">);</span>
				<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">&#39;Initialize header Content-Type to application/x-www-form-urlencoded for POST transaction.&#39;</span><span class="o">,</span> <span class="s1">&#39;info&#39;</span><span class="o">,</span> <span class="s1">&#39;Connection&#39;</span><span class="o">);</span>
				<span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_isFormSubmit</span><span class="o">){</span>
					<span class="k">this</span><span class="o">.</span><span class="nx">resetFormState</span><span class="o">();</span>
				<span class="o">}</span>
			<span class="o">}</span>

			<span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_has_default_headers</span> <span class="o">||</span> <span class="k">this</span><span class="o">.</span><span class="nx">_has_http_headers</span><span class="o">){</span>
				<span class="k">this</span><span class="o">.</span><span class="nx">setHeader</span><span class="o">(</span><span class="nx">o</span><span class="o">);</span>
			<span class="o">}</span>

			<span class="k">this</span><span class="o">.</span><span class="nx">handleReadyState</span><span class="o">(</span><span class="nx">o</span><span class="o">,</span> <span class="nx">callback</span><span class="o">);</span>
			<span class="nx">o</span><span class="o">.</span><span class="nx">conn</span><span class="o">.</span><span class="nx">send</span><span class="o">(</span><span class="nx">postData</span> <span class="o">||</span> <span class="kc">null</span><span class="o">);</span>

			<span class="k">return</span> <span class="nx">o</span><span class="o">;</span>
		<span class="o">}</span>
	<span class="o">},</span>

  <span class="c">/**</span>
<span class="c">   * @description This method serves as a timer that polls the XHR object&#39;s readyState</span>
<span class="c">   * property during a transaction, instead of binding a callback to the</span>
<span class="c">   * onreadystatechange event.  Upon readyState 4, handleTransactionResponse</span>
<span class="c">   * will process the response, and the timer will be cleared.</span>
<span class="c">   * @method handleReadyState</span>
<span class="c">   * @private</span>
<span class="c">   * @static</span>
<span class="c">   * @param {object} o The connection object</span>
<span class="c">   * @param {callback} callback The user-defined callback object</span>
<span class="c">   * @return {void}</span>
<span class="c">   */</span>
    <span class="nx">handleReadyState</span><span class="o">:</span><span class="k">function</span><span class="o">(</span><span class="nx">o</span><span class="o">,</span> <span class="nx">callback</span><span class="o">)</span>
    <span class="o">{</span>
		<span class="k">var</span> <span class="nx">oConn</span> <span class="o">=</span> <span class="k">this</span><span class="o">;</span>

		<span class="k">if</span><span class="o">(</span><span class="nx">callback</span> <span class="o">&amp;&amp;</span> <span class="nx">callback</span><span class="o">.</span><span class="nx">timeout</span><span class="o">){</span>
			<span class="k">this</span><span class="o">.</span><span class="nx">_timeOut</span><span class="o">[</span><span class="nx">o</span><span class="o">.</span><span class="nx">tId</span><span class="o">]</span> <span class="o">=</span> <span class="nb">window</span><span class="o">.</span><span class="nx">setTimeout</span><span class="o">(</span><span class="k">function</span><span class="o">(){</span> <span class="nx">oConn</span><span class="o">.</span><span class="nx">abort</span><span class="o">(</span><span class="nx">o</span><span class="o">,</span> <span class="nx">callback</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span> <span class="o">},</span> <span class="nx">callback</span><span class="o">.</span><span class="nx">timeout</span><span class="o">);</span>
		<span class="o">}</span>

		<span class="k">this</span><span class="o">.</span><span class="nx">_poll</span><span class="o">[</span><span class="nx">o</span><span class="o">.</span><span class="nx">tId</span><span class="o">]</span> <span class="o">=</span> <span class="nb">window</span><span class="o">.</span><span class="nx">setInterval</span><span class="o">(</span>
			<span class="k">function</span><span class="o">(){</span>
				<span class="k">if</span><span class="o">(</span><span class="nx">o</span><span class="o">.</span><span class="nx">conn</span> <span class="o">&amp;&amp;</span> <span class="nx">o</span><span class="o">.</span><span class="nx">conn</span><span class="o">.</span><span class="nx">readyState</span> <span class="o">===</span> <span class="m">4</span><span class="o">){</span>
					<span class="nb">window</span><span class="o">.</span><span class="nx">clearInterval</span><span class="o">(</span><span class="nx">oConn</span><span class="o">.</span><span class="nx">_poll</span><span class="o">[</span><span class="nx">o</span><span class="o">.</span><span class="nx">tId</span><span class="o">]);</span>
					<span class="nx">delete</span> <span class="nx">oConn</span><span class="o">.</span><span class="nx">_poll</span><span class="o">[</span><span class="nx">o</span><span class="o">.</span><span class="nx">tId</span><span class="o">];</span>

					<span class="k">if</span><span class="o">(</span><span class="nx">callback</span> <span class="o">&amp;&amp;</span> <span class="nx">callback</span><span class="o">.</span><span class="nx">timeout</span><span class="o">){</span>
						<span class="nx">delete</span> <span class="nx">oConn</span><span class="o">.</span><span class="nx">_timeOut</span><span class="o">[</span><span class="nx">o</span><span class="o">.</span><span class="nx">tId</span><span class="o">];</span>
					<span class="o">}</span>

					<span class="nx">oConn</span><span class="o">.</span><span class="nx">handleTransactionResponse</span><span class="o">(</span><span class="nx">o</span><span class="o">,</span> <span class="nx">callback</span><span class="o">);</span>
				<span class="o">}</span>
			<span class="o">}</span>
		<span class="o">,</span><span class="k">this</span><span class="o">.</span><span class="nx">_polling_interval</span><span class="o">);</span>
    <span class="o">},</span>

  <span class="c">/**</span>
<span class="c">   * @description This method attempts to interpret the server response and</span>
<span class="c">   * determine whether the transaction was successful, or if an error or</span>
<span class="c">   * exception was encountered.</span>
<span class="c">   * @method handleTransactionResponse</span>
<span class="c">   * @private</span>
<span class="c">   * @static</span>
<span class="c">   * @param {object} o The connection object</span>
<span class="c">   * @param {object} callback The sser-defined callback object</span>
<span class="c">   * @param {boolean} isAbort Determines if the transaction was aborted.</span>
<span class="c">   * @return {void}</span>
<span class="c">   */</span>
    <span class="nx">handleTransactionResponse</span><span class="o">:</span><span class="k">function</span><span class="o">(</span><span class="nx">o</span><span class="o">,</span> <span class="nx">callback</span><span class="o">,</span> <span class="nx">isAbort</span><span class="o">)</span>
    <span class="o">{</span>
		<span class="c">// If no valid callback is provided, then do not process any callback handling.</span>
<span class="c"></span>		<span class="k">if</span><span class="o">(!</span><span class="nx">callback</span><span class="o">){</span>
			<span class="k">this</span><span class="o">.</span><span class="nx">releaseObject</span><span class="o">(</span><span class="nx">o</span><span class="o">);</span>
			<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">&#39;No callback object to process. Transaction complete.&#39;</span><span class="o">,</span> <span class="s1">&#39;warn&#39;</span><span class="o">,</span> <span class="s1">&#39;Connection&#39;</span><span class="o">);</span>
			<span class="k">return</span><span class="o">;</span>
		<span class="o">}</span>

		<span class="k">var</span> <span class="nx">httpStatus</span><span class="o">,</span> <span class="nx">responseObject</span><span class="o">;</span>

		<span class="k">try</span>
		<span class="o">{</span>
			<span class="k">if</span><span class="o">(</span><span class="nx">o</span><span class="o">.</span><span class="nx">conn</span><span class="o">.</span><span class="nx">status</span> <span class="o">!==</span> <span class="kc">undefined</span> <span class="o">&amp;&amp;</span> <span class="nx">o</span><span class="o">.</span><span class="nx">conn</span><span class="o">.</span><span class="nx">status</span> <span class="o">!==</span> <span class="m">0</span><span class="o">){</span>
				<span class="nx">httpStatus</span> <span class="o">=</span> <span class="nx">o</span><span class="o">.</span><span class="nx">conn</span><span class="o">.</span><span class="nx">status</span><span class="o">;</span>
			<span class="o">}</span>
			<span class="k">else</span><span class="o">{</span>
				<span class="nx">httpStatus</span> <span class="o">=</span> <span class="m">13030</span><span class="o">;</span>
			<span class="o">}</span>
		<span class="o">}</span>
		<span class="k">catch</span><span class="o">(</span><span class="nx">e</span><span class="o">){</span>

			 <span class="c">// 13030 is the custom code to indicate the condition -- in Mozilla/FF --</span>
<span class="c"></span>			 <span class="c">// when the o object&#39;s status and statusText properties are</span>
<span class="c"></span>			 <span class="c">// unavailable, and a query attempt throws an exception.</span>
<span class="c"></span>			<span class="nx">httpStatus</span> <span class="o">=</span> <span class="m">13030</span><span class="o">;</span>
		<span class="o">}</span>

		<span class="k">if</span><span class="o">(</span><span class="nx">httpStatus</span> <span class="o">&gt;=</span> <span class="m">200</span> <span class="o">&amp;&amp;</span> <span class="nx">httpStatus</span> <span class="o">&lt;</span> <span class="m">300</span> <span class="o">||</span> <span class="nx">httpStatus</span> <span class="o">===</span> <span class="m">1223</span><span class="o">){</span>
			<span class="nx">responseObject</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">createResponseObject</span><span class="o">(</span><span class="nx">o</span><span class="o">,</span> <span class="nx">callback</span><span class="o">.</span><span class="nx">argument</span><span class="o">);</span>
			<span class="k">if</span><span class="o">(</span><span class="nx">callback</span><span class="o">.</span><span class="nx">success</span><span class="o">){</span>
				<span class="k">if</span><span class="o">(!</span><span class="nx">callback</span><span class="o">.</span><span class="nx">scope</span><span class="o">){</span>
					<span class="nx">callback</span><span class="o">.</span><span class="nx">success</span><span class="o">(</span><span class="nx">responseObject</span><span class="o">);</span>
					<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">&#39;Success callback. HTTP code is &#39;</span> <span class="o">+</span> <span class="nx">httpStatus</span><span class="o">,</span> <span class="s1">&#39;info&#39;</span><span class="o">,</span> <span class="s1">&#39;Connection&#39;</span><span class="o">);</span>
				<span class="o">}</span>
				<span class="k">else</span><span class="o">{</span>
					<span class="c">// If a scope property is defined, the callback will be fired from</span>
<span class="c"></span>					<span class="c">// the context of the object.</span>
<span class="c"></span>					<span class="nx">callback</span><span class="o">.</span><span class="nx">success</span><span class="o">.</span><span class="nx">apply</span><span class="o">(</span><span class="nx">callback</span><span class="o">.</span><span class="nx">scope</span><span class="o">,</span> <span class="o">[</span><span class="nx">responseObject</span><span class="o">]);</span>
					<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">&#39;Success callback with scope. HTTP code is &#39;</span> <span class="o">+</span> <span class="nx">httpStatus</span><span class="o">,</span> <span class="s1">&#39;info&#39;</span><span class="o">,</span> <span class="s1">&#39;Connection&#39;</span><span class="o">);</span>
				<span class="o">}</span>
			<span class="o">}</span>
		<span class="o">}</span>
		<span class="k">else</span><span class="o">{</span>
			<span class="nx">switch</span><span class="o">(</span><span class="nx">httpStatus</span><span class="o">){</span>
				<span class="c">// The following cases are wininet.dll error codes that may be encountered.</span>
<span class="c"></span>				<span class="nx">case</span> <span class="m">12002</span><span class="o">:</span> <span class="c">// Server timeout</span>
<span class="c"></span>				<span class="nx">case</span> <span class="m">12029</span><span class="o">:</span> <span class="c">// 12029 to 12031 correspond to dropped connections.</span>
<span class="c"></span>				<span class="nx">case</span> <span class="m">12030</span><span class="o">:</span>
				<span class="nx">case</span> <span class="m">12031</span><span class="o">:</span>
				<span class="nx">case</span> <span class="m">12152</span><span class="o">:</span> <span class="c">// Connection closed by server.</span>
<span class="c"></span>				<span class="nx">case</span> <span class="m">13030</span><span class="o">:</span> <span class="c">// See above comments for variable status.</span>
<span class="c"></span>					<span class="nx">responseObject</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">createExceptionObject</span><span class="o">(</span><span class="nx">o</span><span class="o">.</span><span class="nx">tId</span><span class="o">,</span> <span class="nx">callback</span><span class="o">.</span><span class="nx">argument</span><span class="o">,</span> <span class="o">(</span><span class="nx">isAbort</span><span class="o">?</span><span class="nx">isAbort</span><span class="o">:</span><span class="kc">false</span><span class="o">));</span>
					<span class="k">if</span><span class="o">(</span><span class="nx">callback</span><span class="o">.</span><span class="nx">failure</span><span class="o">){</span>
						<span class="k">if</span><span class="o">(!</span><span class="nx">callback</span><span class="o">.</span><span class="nx">scope</span><span class="o">){</span>
							<span class="nx">callback</span><span class="o">.</span><span class="nx">failure</span><span class="o">(</span><span class="nx">responseObject</span><span class="o">);</span>
							<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">&#39;Failure callback. Exception detected. Status code is &#39;</span> <span class="o">+</span> <span class="nx">httpStatus</span><span class="o">,</span> <span class="s1">&#39;warn&#39;</span><span class="o">,</span> <span class="s1">&#39;Connection&#39;</span><span class="o">);</span>
						<span class="o">}</span>
						<span class="k">else</span><span class="o">{</span>
							<span class="nx">callback</span><span class="o">.</span><span class="nx">failure</span><span class="o">.</span><span class="nx">apply</span><span class="o">(</span><span class="nx">callback</span><span class="o">.</span><span class="nx">scope</span><span class="o">,</span> <span class="o">[</span><span class="nx">responseObject</span><span class="o">]);</span>
							<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">&#39;Failure callback with scope. Exception detected. Status code is &#39;</span> <span class="o">+</span> <span class="nx">httpStatus</span><span class="o">,</span> <span class="s1">&#39;warn&#39;</span><span class="o">,</span> <span class="s1">&#39;Connection&#39;</span><span class="o">);</span>
						<span class="o">}</span>
					<span class="o">}</span>
					<span class="k">break</span><span class="o">;</span>
				<span class="nx">default</span><span class="o">:</span>
					<span class="nx">responseObject</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">createResponseObject</span><span class="o">(</span><span class="nx">o</span><span class="o">,</span> <span class="nx">callback</span><span class="o">.</span><span class="nx">argument</span><span class="o">);</span>
					<span class="k">if</span><span class="o">(</span><span class="nx">callback</span><span class="o">.</span><span class="nx">failure</span><span class="o">){</span>
						<span class="k">if</span><span class="o">(!</span><span class="nx">callback</span><span class="o">.</span><span class="nx">scope</span><span class="o">){</span>
							<span class="nx">callback</span><span class="o">.</span><span class="nx">failure</span><span class="o">(</span><span class="nx">responseObject</span><span class="o">);</span>
							<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">&#39;Failure callback. HTTP status code is &#39;</span> <span class="o">+</span> <span class="nx">httpStatus</span><span class="o">,</span> <span class="s1">&#39;warn&#39;</span><span class="o">,</span> <span class="s1">&#39;Connection&#39;</span><span class="o">);</span>
						<span class="o">}</span>
						<span class="k">else</span><span class="o">{</span>
							<span class="nx">callback</span><span class="o">.</span><span class="nx">failure</span><span class="o">.</span><span class="nx">apply</span><span class="o">(</span><span class="nx">callback</span><span class="o">.</span><span class="nx">scope</span><span class="o">,</span> <span class="o">[</span><span class="nx">responseObject</span><span class="o">]);</span>
							<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">&#39;Failure callback with scope. HTTP status code is &#39;</span> <span class="o">+</span> <span class="nx">httpStatus</span><span class="o">,</span> <span class="s1">&#39;warn&#39;</span><span class="o">,</span> <span class="s1">&#39;Connection&#39;</span><span class="o">);</span>
						<span class="o">}</span>
					<span class="o">}</span>
			<span class="o">}</span>
		<span class="o">}</span>

		<span class="k">this</span><span class="o">.</span><span class="nx">releaseObject</span><span class="o">(</span><span class="nx">o</span><span class="o">);</span>
		<span class="nx">responseObject</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
    <span class="o">},</span>

  <span class="c">/**</span>
<span class="c">   * @description This method evaluates the server response, creates and returns the results via</span>
<span class="c">   * its properties.  Success and failure cases will differ in the response</span>
<span class="c">   * object&#39;s property values.</span>
<span class="c">   * @method createResponseObject</span>
<span class="c">   * @private</span>
<span class="c">   * @static</span>
<span class="c">   * @param {object} o The connection object</span>
<span class="c">   * @param {callbackArg} callbackArg The user-defined argument or arguments to be passed to the callback</span>
<span class="c">   * @return {object}</span>
<span class="c">   */</span>
    <span class="nx">createResponseObject</span><span class="o">:</span><span class="k">function</span><span class="o">(</span><span class="nx">o</span><span class="o">,</span> <span class="nx">callbackArg</span><span class="o">)</span>
    <span class="o">{</span>
		<span class="k">var</span> <span class="nx">obj</span> <span class="o">=</span> <span class="o">{};</span>
		<span class="k">var</span> <span class="nx">headerObj</span> <span class="o">=</span> <span class="o">{};</span>

		<span class="k">try</span>
		<span class="o">{</span>
			<span class="k">var</span> <span class="nx">headerStr</span> <span class="o">=</span> <span class="nx">o</span><span class="o">.</span><span class="nx">conn</span><span class="o">.</span><span class="nx">getAllResponseHeaders</span><span class="o">();</span>
			<span class="k">var</span> <span class="nx">header</span> <span class="o">=</span> <span class="nx">headerStr</span><span class="o">.</span><span class="nx">split</span><span class="o">(</span><span class="s1">&#39;\n&#39;</span><span class="o">);</span>
			<span class="k">for</span><span class="o">(</span><span class="k">var</span> <span class="nx">i</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">header</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">i</span><span class="o">++){</span>
				<span class="k">var</span> <span class="nx">delimitPos</span> <span class="o">=</span> <span class="nx">header</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">indexOf</span><span class="o">(</span><span class="s1">&#39;:&#39;</span><span class="o">);</span>
				<span class="k">if</span><span class="o">(</span><span class="nx">delimitPos</span> <span class="o">!=</span> <span class="o">-</span><span class="m">1</span><span class="o">){</span>
					<span class="nx">headerObj</span><span class="o">[</span><span class="nx">header</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">substring</span><span class="o">(</span><span class="m">0</span><span class="o">,</span><span class="nx">delimitPos</span><span class="o">)]</span> <span class="o">=</span> <span class="nx">header</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">substring</span><span class="o">(</span><span class="nx">delimitPos</span><span class="o">+</span><span class="m">2</span><span class="o">);</span>
				<span class="o">}</span>
			<span class="o">}</span>
		<span class="o">}</span>
		<span class="k">catch</span><span class="o">(</span><span class="nx">e</span><span class="o">){}</span>

		<span class="nx">obj</span><span class="o">.</span><span class="nx">tId</span> <span class="o">=</span> <span class="nx">o</span><span class="o">.</span><span class="nx">tId</span><span class="o">;</span>
		<span class="c">// Normalize IE&#39;s response to HTTP 204 when Win error 1223.</span>
<span class="c"></span>		<span class="nx">obj</span><span class="o">.</span><span class="nx">status</span> <span class="o">=</span> <span class="o">(</span><span class="nx">o</span><span class="o">.</span><span class="nx">conn</span><span class="o">.</span><span class="nx">status</span> <span class="o">==</span> <span class="m">1223</span><span class="o">)?</span><span class="m">204</span><span class="o">:</span><span class="nx">o</span><span class="o">.</span><span class="nx">conn</span><span class="o">.</span><span class="nx">status</span><span class="o">;</span>
		<span class="c">// Normalize IE&#39;s statusText to &quot;No Content&quot; instead of &quot;Unknown&quot;.</span>
<span class="c"></span>		<span class="nx">obj</span><span class="o">.</span><span class="nx">statusText</span> <span class="o">=</span> <span class="o">(</span><span class="nx">o</span><span class="o">.</span><span class="nx">conn</span><span class="o">.</span><span class="nx">status</span> <span class="o">==</span> <span class="m">1223</span><span class="o">)?</span><span class="s2">&quot;No Content&quot;</span><span class="o">:</span><span class="nx">o</span><span class="o">.</span><span class="nx">conn</span><span class="o">.</span><span class="nx">statusText</span><span class="o">;</span>
		<span class="nx">obj</span><span class="o">.</span><span class="nx">getResponseHeader</span> <span class="o">=</span> <span class="nx">headerObj</span><span class="o">;</span>
		<span class="nx">obj</span><span class="o">.</span><span class="nx">getAllResponseHeaders</span> <span class="o">=</span> <span class="nx">headerStr</span><span class="o">;</span>
		<span class="nx">obj</span><span class="o">.</span><span class="nx">responseText</span> <span class="o">=</span> <span class="nx">o</span><span class="o">.</span><span class="nx">conn</span><span class="o">.</span><span class="nx">responseText</span><span class="o">;</span>
		<span class="nx">obj</span><span class="o">.</span><span class="nx">responseXML</span> <span class="o">=</span> <span class="nx">o</span><span class="o">.</span><span class="nx">conn</span><span class="o">.</span><span class="nx">responseXML</span><span class="o">;</span>

		<span class="k">if</span><span class="o">(</span><span class="k">typeof</span> <span class="nx">callbackArg</span> <span class="o">!==</span> <span class="kc">undefined</span><span class="o">){</span>
			<span class="nx">obj</span><span class="o">.</span><span class="nx">argument</span> <span class="o">=</span> <span class="nx">callbackArg</span><span class="o">;</span>
		<span class="o">}</span>

		<span class="k">return</span> <span class="nx">obj</span><span class="o">;</span>
    <span class="o">},</span>

  <span class="c">/**</span>
<span class="c">   * @description If a transaction cannot be completed due to dropped or closed connections,</span>
<span class="c">   * there may be not be enough information to build a full response object.</span>
<span class="c">   * The failure callback will be fired and this specific condition can be identified</span>
<span class="c">   * by a status property value of 0.</span>
<span class="c">   *</span>
<span class="c">   * If an abort was successful, the status property will report a value of -1.</span>
<span class="c">   *</span>
<span class="c">   * @method createExceptionObject</span>
<span class="c">   * @private</span>
<span class="c">   * @static</span>
<span class="c">   * @param {int} tId The Transaction Id</span>
<span class="c">   * @param {callbackArg} callbackArg The user-defined argument or arguments to be passed to the callback</span>
<span class="c">   * @param {boolean} isAbort Determines if the exception case is caused by a transaction abort</span>
<span class="c">   * @return {object}</span>
<span class="c">   */</span>
    <span class="nx">createExceptionObject</span><span class="o">:</span><span class="k">function</span><span class="o">(</span><span class="nx">tId</span><span class="o">,</span> <span class="nx">callbackArg</span><span class="o">,</span> <span class="nx">isAbort</span><span class="o">)</span>
    <span class="o">{</span>
		<span class="k">var</span> <span class="nx">COMM_CODE</span> <span class="o">=</span> <span class="m">0</span><span class="o">;</span>
		<span class="k">var</span> <span class="nx">COMM_ERROR</span> <span class="o">=</span> <span class="s1">&#39;communication failure&#39;</span><span class="o">;</span>
		<span class="k">var</span> <span class="nx">ABORT_CODE</span> <span class="o">=</span> <span class="o">-</span><span class="m">1</span><span class="o">;</span>
		<span class="k">var</span> <span class="nx">ABORT_ERROR</span> <span class="o">=</span> <span class="s1">&#39;transaction aborted&#39;</span><span class="o">;</span>

		<span class="k">var</span> <span class="nx">obj</span> <span class="o">=</span> <span class="o">{};</span>

		<span class="nx">obj</span><span class="o">.</span><span class="nx">tId</span> <span class="o">=</span> <span class="nx">tId</span><span class="o">;</span>
		<span class="k">if</span><span class="o">(</span><span class="nx">isAbort</span><span class="o">){</span>
			<span class="nx">obj</span><span class="o">.</span><span class="nx">status</span> <span class="o">=</span> <span class="nx">ABORT_CODE</span><span class="o">;</span>
			<span class="nx">obj</span><span class="o">.</span><span class="nx">statusText</span> <span class="o">=</span> <span class="nx">ABORT_ERROR</span><span class="o">;</span>
		<span class="o">}</span>
		<span class="k">else</span><span class="o">{</span>
			<span class="nx">obj</span><span class="o">.</span><span class="nx">status</span> <span class="o">=</span> <span class="nx">COMM_CODE</span><span class="o">;</span>
			<span class="nx">obj</span><span class="o">.</span><span class="nx">statusText</span> <span class="o">=</span> <span class="nx">COMM_ERROR</span><span class="o">;</span>
		<span class="o">}</span>

		<span class="k">if</span><span class="o">(</span><span class="nx">callbackArg</span><span class="o">){</span>
			<span class="nx">obj</span><span class="o">.</span><span class="nx">argument</span> <span class="o">=</span> <span class="nx">callbackArg</span><span class="o">;</span>
		<span class="o">}</span>

		<span class="k">return</span> <span class="nx">obj</span><span class="o">;</span>
    <span class="o">},</span>

  <span class="c">/**</span>
<span class="c">   * @description Method that initializes the custom HTTP headers for the each transaction.</span>
<span class="c">   * @method initHeader</span>
<span class="c">   * @public</span>
<span class="c">   * @static</span>
<span class="c">   * @param {string} label The HTTP header label</span>
<span class="c">   * @param {string} value The HTTP header value</span>
<span class="c">   * @param {string} isDefault Determines if the specific header is a default header</span>
<span class="c">   * automatically sent with each transaction.</span>
<span class="c">   * @return {void}</span>
<span class="c">   */</span>
	<span class="nx">initHeader</span><span class="o">:</span><span class="k">function</span><span class="o">(</span><span class="k">label</span><span class="o">,</span><span class="nx">value</span><span class="o">,</span><span class="nx">isDefault</span><span class="o">)</span>
	<span class="o">{</span>
		<span class="k">var</span> <span class="nx">headerObj</span> <span class="o">=</span> <span class="o">(</span><span class="nx">isDefault</span><span class="o">)?</span><span class="k">this</span><span class="o">.</span><span class="nx">_default_headers</span><span class="o">:</span><span class="k">this</span><span class="o">.</span><span class="nx">_http_headers</span><span class="o">;</span>

		<span class="k">if</span><span class="o">(</span><span class="nx">headerObj</span><span class="o">[</span><span class="k">label</span><span class="o">]</span> <span class="o">===</span> <span class="kc">undefined</span><span class="o">){</span>
			<span class="nx">headerObj</span><span class="o">[</span><span class="k">label</span><span class="o">]</span> <span class="o">=</span> <span class="nx">value</span><span class="o">;</span>
		<span class="o">}</span>
		<span class="k">else</span><span class="o">{</span>
			<span class="c">// Concatenate multiple values, comma-delimited,</span>
<span class="c"></span>			<span class="c">// for the same header label,</span>
<span class="c"></span>			<span class="nx">headerObj</span><span class="o">[</span><span class="k">label</span><span class="o">]</span> <span class="o">=</span>  <span class="nx">value</span> <span class="o">+</span> <span class="s2">&quot;,&quot;</span> <span class="o">+</span> <span class="nx">headerObj</span><span class="o">[</span><span class="k">label</span><span class="o">];</span>
		<span class="o">}</span>

		<span class="k">if</span><span class="o">(</span><span class="nx">isDefault</span><span class="o">){</span>
			<span class="k">this</span><span class="o">.</span><span class="nx">_has_default_headers</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
		<span class="o">}</span>
		<span class="k">else</span><span class="o">{</span>
			<span class="k">this</span><span class="o">.</span><span class="nx">_has_http_headers</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
		<span class="o">}</span>
	<span class="o">},</span>


  <span class="c">/**</span>
<span class="c">   * @description Accessor that sets the HTTP headers for each transaction.</span>
<span class="c">   * @method setHeader</span>
<span class="c">   * @private</span>
<span class="c">   * @static</span>
<span class="c">   * @param {object} o The connection object for the transaction.</span>
<span class="c">   * @return {void}</span>
<span class="c">   */</span>
	<span class="nx">setHeader</span><span class="o">:</span><span class="k">function</span><span class="o">(</span><span class="nx">o</span><span class="o">)</span>
	<span class="o">{</span>
		<span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_has_default_headers</span><span class="o">){</span>
			<span class="k">for</span><span class="o">(</span><span class="k">var</span> <span class="nx">prop</span> <span class="k">in</span> <span class="k">this</span><span class="o">.</span><span class="nx">_default_headers</span><span class="o">){</span>
				<span class="k">if</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">hasOwnProperty</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_default_headers</span><span class="o">,</span><span class="nx">prop</span><span class="o">)){</span>
					<span class="nx">o</span><span class="o">.</span><span class="nx">conn</span><span class="o">.</span><span class="nx">setRequestHeader</span><span class="o">(</span><span class="nx">prop</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_default_headers</span><span class="o">[</span><span class="nx">prop</span><span class="o">]);</span>
					<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">&#39;Default HTTP header &#39;</span> <span class="o">+</span> <span class="nx">prop</span> <span class="o">+</span> <span class="s1">&#39; set with value of &#39;</span> <span class="o">+</span> <span class="k">this</span><span class="o">.</span><span class="nx">_default_headers</span><span class="o">[</span><span class="nx">prop</span><span class="o">],</span> <span class="s1">&#39;info&#39;</span><span class="o">,</span> <span class="s1">&#39;Connection&#39;</span><span class="o">);</span>
				<span class="o">}</span>
			<span class="o">}</span>
		<span class="o">}</span>

		<span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_has_http_headers</span><span class="o">){</span>
			<span class="k">for</span><span class="o">(</span><span class="k">var</span> <span class="nx">prop</span> <span class="k">in</span> <span class="k">this</span><span class="o">.</span><span class="nx">_http_headers</span><span class="o">){</span>
				<span class="k">if</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">.</span><span class="nx">hasOwnProperty</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_http_headers</span><span class="o">,</span><span class="nx">prop</span><span class="o">)){</span>
					<span class="nx">o</span><span class="o">.</span><span class="nx">conn</span><span class="o">.</span><span class="nx">setRequestHeader</span><span class="o">(</span><span class="nx">prop</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_http_headers</span><span class="o">[</span><span class="nx">prop</span><span class="o">]);</span>
					<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">&#39;HTTP header &#39;</span> <span class="o">+</span> <span class="nx">prop</span> <span class="o">+</span> <span class="s1">&#39; set with value of &#39;</span> <span class="o">+</span> <span class="k">this</span><span class="o">.</span><span class="nx">_http_headers</span><span class="o">[</span><span class="nx">prop</span><span class="o">],</span> <span class="s1">&#39;info&#39;</span><span class="o">,</span> <span class="s1">&#39;Connection&#39;</span><span class="o">);</span>
				<span class="o">}</span>
			<span class="o">}</span>
			<span class="nx">delete</span> <span class="k">this</span><span class="o">.</span><span class="nx">_http_headers</span><span class="o">;</span>

			<span class="k">this</span><span class="o">.</span><span class="nx">_http_headers</span> <span class="o">=</span> <span class="o">{};</span>
			<span class="k">this</span><span class="o">.</span><span class="nx">_has_http_headers</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>
		<span class="o">}</span>
	<span class="o">},</span>

  <span class="c">/**</span>
<span class="c">   * @description Resets the default HTTP headers object</span>
<span class="c">   * @method resetDefaultHeaders</span>
<span class="c">   * @public</span>
<span class="c">   * @static</span>
<span class="c">   * @return {void}</span>
<span class="c">   */</span>
	<span class="nx">resetDefaultHeaders</span><span class="o">:</span><span class="k">function</span><span class="o">(){</span>
		<span class="nx">delete</span> <span class="k">this</span><span class="o">.</span><span class="nx">_default_headers</span>
		<span class="k">this</span><span class="o">.</span><span class="nx">_default_headers</span> <span class="o">=</span> <span class="o">{};</span>
		<span class="k">this</span><span class="o">.</span><span class="nx">_has_default_headers</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>
	<span class="o">},</span>

  <span class="c">/**</span>
<span class="c">   * @description This method assembles the form label and value pairs and</span>
<span class="c">   * constructs an encoded string.</span>
<span class="c">   * asyncRequest() will automatically initialize the</span>
<span class="c">   * transaction with a HTTP header Content-Type of</span>
<span class="c">   * application/x-www-form-urlencoded.</span>
<span class="c">   * @method setForm</span>
<span class="c">   * @public</span>
<span class="c">   * @static</span>
<span class="c">   * @param {string || object} form id or name attribute, or form object.</span>
<span class="c">   * @param {string} optional boolean to indicate SSL environment.</span>
<span class="c">   * @param {string || boolean} optional qualified path of iframe resource for SSL in IE.</span>
<span class="c">   * @return {string} string of the HTML form field name and value pairs..</span>
<span class="c">   */</span>
	<span class="nx">setForm</span><span class="o">:</span><span class="k">function</span><span class="o">(</span><span class="nx">formId</span><span class="o">,</span> <span class="nx">isUpload</span><span class="o">,</span> <span class="nx">secureUri</span><span class="o">)</span>
	<span class="o">{</span>
		<span class="k">this</span><span class="o">.</span><span class="nx">resetFormState</span><span class="o">();</span>
		<span class="k">var</span> <span class="nx">oForm</span><span class="o">;</span>
		<span class="k">if</span><span class="o">(</span><span class="k">typeof</span> <span class="nx">formId</span> <span class="o">==</span> <span class="s1">&#39;string&#39;</span><span class="o">){</span>
			<span class="c">// Determine if the argument is a form id or a form name.</span>
<span class="c"></span>			<span class="c">// Note form name usage is deprecated by supported</span>
<span class="c"></span>			<span class="c">// here for legacy reasons.</span>
<span class="c"></span>			<span class="nx">oForm</span> <span class="o">=</span> <span class="o">(</span><span class="nb">document</span><span class="o">.</span><span class="nx">getElementById</span><span class="o">(</span><span class="nx">formId</span><span class="o">)</span> <span class="o">||</span> <span class="nb">document</span><span class="o">.</span><span class="nx">forms</span><span class="o">[</span><span class="nx">formId</span><span class="o">]);</span>
		<span class="o">}</span>
		<span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="k">typeof</span> <span class="nx">formId</span> <span class="o">==</span> <span class="s1">&#39;object&#39;</span><span class="o">){</span>
			<span class="c">// Treat argument as an HTML form object.</span>
<span class="c"></span>			<span class="nx">oForm</span> <span class="o">=</span> <span class="nx">formId</span><span class="o">;</span>
		<span class="o">}</span>
		<span class="k">else</span><span class="o">{</span>
			<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">&#39;Unable to create form object &#39;</span> <span class="o">+</span> <span class="nx">formId</span><span class="o">,</span> <span class="s1">&#39;warn&#39;</span><span class="o">,</span> <span class="s1">&#39;Connection&#39;</span><span class="o">);</span>
			<span class="k">return</span><span class="o">;</span>
		<span class="o">}</span>

		<span class="c">// If the isUpload argument is true, setForm will call createFrame to initialize</span>
<span class="c"></span>		<span class="c">// an iframe as the form target.</span>
<span class="c"></span>		<span class="c">//</span>
<span class="c"></span>		<span class="c">// The argument secureURI is also required by IE in SSL environments</span>
<span class="c"></span>		<span class="c">// where the secureURI string is a fully qualified HTTP path, used to set the source</span>
<span class="c"></span>		<span class="c">// of the iframe, to a stub resource in the same domain.</span>
<span class="c"></span>		<span class="k">if</span><span class="o">(</span><span class="nx">isUpload</span><span class="o">){</span>

			<span class="c">// Create iframe in preparation for file upload.</span>
<span class="c"></span>			<span class="k">this</span><span class="o">.</span><span class="nx">createFrame</span><span class="o">(</span><span class="nx">secureUri</span><span class="o">?</span><span class="nx">secureUri</span><span class="o">:</span><span class="kc">null</span><span class="o">);</span>

			<span class="c">// Set form reference and file upload properties to true.</span>
<span class="c"></span>			<span class="k">this</span><span class="o">.</span><span class="nx">_isFormSubmit</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
			<span class="k">this</span><span class="o">.</span><span class="nx">_isFileUpload</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
			<span class="k">this</span><span class="o">.</span><span class="nx">_formNode</span> <span class="o">=</span> <span class="nx">oForm</span><span class="o">;</span>

			<span class="k">return</span><span class="o">;</span>
		<span class="o">}</span>

		<span class="k">var</span> <span class="nx">oElement</span><span class="o">,</span> <span class="nx">oName</span><span class="o">,</span> <span class="nx">oValue</span><span class="o">,</span> <span class="nx">oDisabled</span><span class="o">;</span>
		<span class="k">var</span> <span class="nx">hasSubmit</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>

		<span class="c">// Iterate over the form elements collection to construct the</span>
<span class="c"></span>		<span class="c">// label-value pairs.</span>
<span class="c"></span>		<span class="k">for</span> <span class="o">(</span><span class="k">var</span> <span class="nx">i</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">oForm</span><span class="o">.</span><span class="nx">elements</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">i</span><span class="o">++){</span>
			<span class="nx">oElement</span> <span class="o">=</span> <span class="nx">oForm</span><span class="o">.</span><span class="nx">elements</span><span class="o">[</span><span class="nx">i</span><span class="o">];</span>
			<span class="nx">oDisabled</span> <span class="o">=</span> <span class="nx">oForm</span><span class="o">.</span><span class="nx">elements</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">disabled</span><span class="o">;</span>
			<span class="nx">oName</span> <span class="o">=</span> <span class="nx">oForm</span><span class="o">.</span><span class="nx">elements</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">name</span><span class="o">;</span>
			<span class="nx">oValue</span> <span class="o">=</span> <span class="nx">oForm</span><span class="o">.</span><span class="nx">elements</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">value</span><span class="o">;</span>

			<span class="c">// Do not submit fields that are disabled or</span>
<span class="c"></span>			<span class="c">// do not have a name attribute value.</span>
<span class="c"></span>			<span class="k">if</span><span class="o">(!</span><span class="nx">oDisabled</span> <span class="o">&amp;&amp;</span> <span class="nx">oName</span><span class="o">)</span>
			<span class="o">{</span>
				<span class="nx">switch</span> <span class="o">(</span><span class="nx">oElement</span><span class="o">.</span><span class="nx">type</span><span class="o">)</span>
				<span class="o">{</span>
					<span class="nx">case</span> <span class="s1">&#39;select-one&#39;</span><span class="o">:</span>
					<span class="nx">case</span> <span class="s1">&#39;select-multiple&#39;</span><span class="o">:</span>
						<span class="k">for</span><span class="o">(</span><span class="k">var</span> <span class="nx">j</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">j</span><span class="o">&lt;</span><span class="nx">oElement</span><span class="o">.</span><span class="nx">options</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">j</span><span class="o">++){</span>
							<span class="k">if</span><span class="o">(</span><span class="nx">oElement</span><span class="o">.</span><span class="nx">options</span><span class="o">[</span><span class="nx">j</span><span class="o">].</span><span class="nx">selected</span><span class="o">){</span>
								<span class="k">if</span><span class="o">(</span><span class="nb">window</span><span class="o">.</span><span class="nx">ActiveXObject</span><span class="o">){</span>
									<span class="k">this</span><span class="o">.</span><span class="nx">_sFormData</span> <span class="o">+=</span> <span class="nb">encodeURIComponent</span><span class="o">(</span><span class="nx">oName</span><span class="o">)</span> <span class="o">+</span> <span class="s1">&#39;=&#39;</span> <span class="o">+</span> <span class="nb">encodeURIComponent</span><span class="o">(</span><span class="nx">oElement</span><span class="o">.</span><span class="nx">options</span><span class="o">[</span><span class="nx">j</span><span class="o">].</span><span class="nx">attributes</span><span class="o">[</span><span class="s1">&#39;value&#39;</span><span class="o">].</span><span class="nx">specified</span><span class="o">?</span><span class="nx">oElement</span><span class="o">.</span><span class="nx">options</span><span class="o">[</span><span class="nx">j</span><span class="o">].</span><span class="nx">value</span><span class="o">:</span><span class="nx">oElement</span><span class="o">.</span><span class="nx">options</span><span class="o">[</span><span class="nx">j</span><span class="o">].</span><span class="nx">text</span><span class="o">)</span> <span class="o">+</span> <span class="s1">&#39;&amp;&#39;</span><span class="o">;</span>
								<span class="o">}</span>
								<span class="k">else</span><span class="o">{</span>
									<span class="k">this</span><span class="o">.</span><span class="nx">_sFormData</span> <span class="o">+=</span> <span class="nb">encodeURIComponent</span><span class="o">(</span><span class="nx">oName</span><span class="o">)</span> <span class="o">+</span> <span class="s1">&#39;=&#39;</span> <span class="o">+</span> <span class="nb">encodeURIComponent</span><span class="o">(</span><span class="nx">oElement</span><span class="o">.</span><span class="nx">options</span><span class="o">[</span><span class="nx">j</span><span class="o">].</span><span class="nx">hasAttribute</span><span class="o">(</span><span class="s1">&#39;value&#39;</span><span class="o">)?</span><span class="nx">oElement</span><span class="o">.</span><span class="nx">options</span><span class="o">[</span><span class="nx">j</span><span class="o">].</span><span class="nx">value</span><span class="o">:</span><span class="nx">oElement</span><span class="o">.</span><span class="nx">options</span><span class="o">[</span><span class="nx">j</span><span class="o">].</span><span class="nx">text</span><span class="o">)</span> <span class="o">+</span> <span class="s1">&#39;&amp;&#39;</span><span class="o">;</span>
								<span class="o">}</span>

							<span class="o">}</span>
						<span class="o">}</span>
						<span class="k">break</span><span class="o">;</span>
					<span class="nx">case</span> <span class="s1">&#39;radio&#39;</span><span class="o">:</span>
					<span class="nx">case</span> <span class="s1">&#39;checkbox&#39;</span><span class="o">:</span>
						<span class="k">if</span><span class="o">(</span><span class="nx">oElement</span><span class="o">.</span><span class="nx">checked</span><span class="o">){</span>
							<span class="k">this</span><span class="o">.</span><span class="nx">_sFormData</span> <span class="o">+=</span> <span class="nb">encodeURIComponent</span><span class="o">(</span><span class="nx">oName</span><span class="o">)</span> <span class="o">+</span> <span class="s1">&#39;=&#39;</span> <span class="o">+</span> <span class="nb">encodeURIComponent</span><span class="o">(</span><span class="nx">oValue</span><span class="o">)</span> <span class="o">+</span> <span class="s1">&#39;&amp;&#39;</span><span class="o">;</span>
						<span class="o">}</span>
						<span class="k">break</span><span class="o">;</span>
					<span class="nx">case</span> <span class="s1">&#39;file&#39;</span><span class="o">:</span>
						<span class="c">// stub case as XMLHttpRequest will only send the file path as a string.</span>
<span class="c"></span>					<span class="nx">case</span> <span class="kc">undefined</span><span class="o">:</span>
						<span class="c">// stub case for fieldset element which returns undefined.</span>
<span class="c"></span>					<span class="nx">case</span> <span class="s1">&#39;reset&#39;</span><span class="o">:</span>
						<span class="c">// stub case for input type reset button.</span>
<span class="c"></span>					<span class="nx">case</span> <span class="s1">&#39;button&#39;</span><span class="o">:</span>
						<span class="c">// stub case for input type button elements.</span>
<span class="c"></span>						<span class="k">break</span><span class="o">;</span>
					<span class="nx">case</span> <span class="s1">&#39;submit&#39;</span><span class="o">:</span>
						<span class="k">if</span><span class="o">(</span><span class="nx">hasSubmit</span> <span class="o">===</span> <span class="kc">false</span><span class="o">){</span>
							<span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_hasSubmitListener</span><span class="o">){</span>
								<span class="k">this</span><span class="o">.</span><span class="nx">_sFormData</span> <span class="o">+=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_submitElementValue</span> <span class="o">+</span> <span class="s1">&#39;&amp;&#39;</span><span class="o">;</span>
							<span class="o">}</span>
							<span class="k">else</span><span class="o">{</span>
								<span class="k">this</span><span class="o">.</span><span class="nx">_sFormData</span> <span class="o">+=</span> <span class="nb">encodeURIComponent</span><span class="o">(</span><span class="nx">oName</span><span class="o">)</span> <span class="o">+</span> <span class="s1">&#39;=&#39;</span> <span class="o">+</span> <span class="nb">encodeURIComponent</span><span class="o">(</span><span class="nx">oValue</span><span class="o">)</span> <span class="o">+</span> <span class="s1">&#39;&amp;&#39;</span><span class="o">;</span>
							<span class="o">}</span>

							<span class="nx">hasSubmit</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
						<span class="o">}</span>
						<span class="k">break</span><span class="o">;</span>
					<span class="nx">default</span><span class="o">:</span>
						<span class="k">this</span><span class="o">.</span><span class="nx">_sFormData</span> <span class="o">+=</span> <span class="nb">encodeURIComponent</span><span class="o">(</span><span class="nx">oName</span><span class="o">)</span> <span class="o">+</span> <span class="s1">&#39;=&#39;</span> <span class="o">+</span> <span class="nb">encodeURIComponent</span><span class="o">(</span><span class="nx">oValue</span><span class="o">)</span> <span class="o">+</span> <span class="s1">&#39;&amp;&#39;</span><span class="o">;</span>
						<span class="k">break</span><span class="o">;</span>
				<span class="o">}</span>
			<span class="o">}</span>
		<span class="o">}</span>

		<span class="k">this</span><span class="o">.</span><span class="nx">_isFormSubmit</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
		<span class="k">this</span><span class="o">.</span><span class="nx">_sFormData</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_sFormData</span><span class="o">.</span><span class="nx">substr</span><span class="o">(</span><span class="m">0</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_sFormData</span><span class="o">.</span><span class="nx">length</span> <span class="o">-</span> <span class="m">1</span><span class="o">);</span>

		<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">&#39;Form initialized for transaction. HTML form POST message is: &#39;</span> <span class="o">+</span> <span class="k">this</span><span class="o">.</span><span class="nx">_sFormData</span><span class="o">,</span> <span class="s1">&#39;info&#39;</span><span class="o">,</span> <span class="s1">&#39;Connection&#39;</span><span class="o">);</span>

		<span class="k">return</span> <span class="k">this</span><span class="o">.</span><span class="nx">_sFormData</span><span class="o">;</span>
	<span class="o">},</span>

  <span class="c">/**</span>
<span class="c">   * @description Resets HTML form properties when an HTML form or HTML form</span>
<span class="c">   * with file upload transaction is sent.</span>
<span class="c">   * @method resetFormState</span>
<span class="c">   * @private</span>
<span class="c">   * @static</span>
<span class="c">   * @return {void}</span>
<span class="c">   */</span>
	<span class="nx">resetFormState</span><span class="o">:</span><span class="k">function</span><span class="o">(){</span>
		<span class="k">this</span><span class="o">.</span><span class="nx">_isFormSubmit</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>
		<span class="k">this</span><span class="o">.</span><span class="nx">_isFileUpload</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>
		<span class="k">this</span><span class="o">.</span><span class="nx">_formNode</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
		<span class="k">this</span><span class="o">.</span><span class="nx">_sFormData</span> <span class="o">=</span> <span class="s2">&quot;&quot;</span><span class="o">;</span>
	<span class="o">},</span>

  <span class="c">/**</span>
<span class="c">   * @description Creates an iframe to be used for form file uploads.  It is remove from the</span>
<span class="c">   * document upon completion of the upload transaction.</span>
<span class="c">   * @method createFrame</span>
<span class="c">   * @private</span>
<span class="c">   * @static</span>
<span class="c">   * @param {string} optional qualified path of iframe resource for SSL in IE.</span>
<span class="c">   * @return {void}</span>
<span class="c">   */</span>
	<span class="nx">createFrame</span><span class="o">:</span><span class="k">function</span><span class="o">(</span><span class="nx">secureUri</span><span class="o">){</span>

		<span class="c">// IE does not allow the setting of id and name attributes as object</span>
<span class="c"></span>		<span class="c">// properties via createElement().  A different iframe creation</span>
<span class="c"></span>		<span class="c">// pattern is required for IE.</span>
<span class="c"></span>		<span class="k">var</span> <span class="nx">frameId</span> <span class="o">=</span> <span class="s1">&#39;yuiIO&#39;</span> <span class="o">+</span> <span class="k">this</span><span class="o">.</span><span class="nx">_transaction_id</span><span class="o">;</span>
		<span class="k">if</span><span class="o">(</span><span class="nb">window</span><span class="o">.</span><span class="nx">ActiveXObject</span><span class="o">){</span>
			<span class="k">var</span> <span class="nx">io</span> <span class="o">=</span> <span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="s1">&#39;&lt;iframe id=&quot;&#39;</span> <span class="o">+</span> <span class="nx">frameId</span> <span class="o">+</span> <span class="s1">&#39;&quot; name=&quot;&#39;</span> <span class="o">+</span> <span class="nx">frameId</span> <span class="o">+</span> <span class="s1">&#39;&quot; /&gt;&#39;</span><span class="o">);</span>

			<span class="c">// IE will throw a security exception in an SSL environment if the</span>
<span class="c"></span>			<span class="c">// iframe source is undefined.</span>
<span class="c"></span>			<span class="k">if</span><span class="o">(</span><span class="k">typeof</span> <span class="nx">secureUri</span> <span class="o">==</span> <span class="s1">&#39;boolean&#39;</span><span class="o">){</span>
				<span class="nx">io</span><span class="o">.</span><span class="nx">src</span> <span class="o">=</span> <span class="s1">&#39;javascript:false&#39;</span><span class="o">;</span>
			<span class="o">}</span>
			<span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="k">typeof</span> <span class="nx">secureURI</span> <span class="o">==</span> <span class="s1">&#39;string&#39;</span><span class="o">){</span>
				<span class="c">// Deprecated</span>
<span class="c"></span>				<span class="nx">io</span><span class="o">.</span><span class="nx">src</span> <span class="o">=</span> <span class="nx">secureUri</span><span class="o">;</span>
			<span class="o">}</span>
		<span class="o">}</span>
		<span class="k">else</span><span class="o">{</span>
			<span class="k">var</span> <span class="nx">io</span> <span class="o">=</span> <span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="s1">&#39;iframe&#39;</span><span class="o">);</span>
			<span class="nx">io</span><span class="o">.</span><span class="nx">id</span> <span class="o">=</span> <span class="nx">frameId</span><span class="o">;</span>
			<span class="nx">io</span><span class="o">.</span><span class="nx">name</span> <span class="o">=</span> <span class="nx">frameId</span><span class="o">;</span>
		<span class="o">}</span>

		<span class="nx">io</span><span class="o">.</span><span class="nx">style</span><span class="o">.</span><span class="nx">position</span> <span class="o">=</span> <span class="s1">&#39;absolute&#39;</span><span class="o">;</span>
		<span class="nx">io</span><span class="o">.</span><span class="nx">style</span><span class="o">.</span><span class="nx">top</span> <span class="o">=</span> <span class="s1">&#39;-1000px&#39;</span><span class="o">;</span>
		<span class="nx">io</span><span class="o">.</span><span class="nx">style</span><span class="o">.</span><span class="nx">left</span> <span class="o">=</span> <span class="s1">&#39;-1000px&#39;</span><span class="o">;</span>

		<span class="nb">document</span><span class="o">.</span><span class="nx">body</span><span class="o">.</span><span class="nx">appendChild</span><span class="o">(</span><span class="nx">io</span><span class="o">);</span>
		<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">&#39;File upload iframe created. Id is:&#39;</span> <span class="o">+</span> <span class="nx">frameId</span><span class="o">,</span> <span class="s1">&#39;info&#39;</span><span class="o">,</span> <span class="s1">&#39;Connection&#39;</span><span class="o">);</span>
	<span class="o">},</span>

  <span class="c">/**</span>
<span class="c">   * @description Parses the POST data and creates hidden form elements</span>
<span class="c">   * for each key-value, and appends them to the HTML form object.</span>
<span class="c">   * @method appendPostData</span>
<span class="c">   * @private</span>
<span class="c">   * @static</span>
<span class="c">   * @param {string} postData The HTTP POST data</span>
<span class="c">   * @return {array} formElements Collection of hidden fields.</span>
<span class="c">   */</span>
	<span class="nx">appendPostData</span><span class="o">:</span><span class="k">function</span><span class="o">(</span><span class="nx">postData</span><span class="o">)</span>
	<span class="o">{</span>
		<span class="k">var</span> <span class="nx">formElements</span> <span class="o">=</span> <span class="o">[];</span>
		<span class="k">var</span> <span class="nx">postMessage</span> <span class="o">=</span> <span class="nx">postData</span><span class="o">.</span><span class="nx">split</span><span class="o">(</span><span class="s1">&#39;&amp;&#39;</span><span class="o">);</span>
		<span class="k">for</span><span class="o">(</span><span class="k">var</span> <span class="nx">i</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">i</span> <span class="o">&lt;</span> <span class="nx">postMessage</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">i</span><span class="o">++){</span>
			<span class="k">var</span> <span class="nx">delimitPos</span> <span class="o">=</span> <span class="nx">postMessage</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">indexOf</span><span class="o">(</span><span class="s1">&#39;=&#39;</span><span class="o">);</span>
			<span class="k">if</span><span class="o">(</span><span class="nx">delimitPos</span> <span class="o">!=</span> <span class="o">-</span><span class="m">1</span><span class="o">){</span>
				<span class="nx">formElements</span><span class="o">[</span><span class="nx">i</span><span class="o">]</span> <span class="o">=</span> <span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="s1">&#39;input&#39;</span><span class="o">);</span>
				<span class="nx">formElements</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">type</span> <span class="o">=</span> <span class="s1">&#39;hidden&#39;</span><span class="o">;</span>
				<span class="nx">formElements</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">name</span> <span class="o">=</span> <span class="nx">postMessage</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">substring</span><span class="o">(</span><span class="m">0</span><span class="o">,</span><span class="nx">delimitPos</span><span class="o">);</span>
				<span class="nx">formElements</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">value</span> <span class="o">=</span> <span class="nx">postMessage</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">substring</span><span class="o">(</span><span class="nx">delimitPos</span><span class="o">+</span><span class="m">1</span><span class="o">);</span>
				<span class="k">this</span><span class="o">.</span><span class="nx">_formNode</span><span class="o">.</span><span class="nx">appendChild</span><span class="o">(</span><span class="nx">formElements</span><span class="o">[</span><span class="nx">i</span><span class="o">]);</span>
			<span class="o">}</span>
		<span class="o">}</span>

		<span class="k">return</span> <span class="nx">formElements</span><span class="o">;</span>
	<span class="o">},</span>

  <span class="c">/**</span>
<span class="c">   * @description Uploads HTML form, including files/attachments, to the</span>
<span class="c">   * iframe created in createFrame.</span>
<span class="c">   * @method uploadFile</span>
<span class="c">   * @private</span>
<span class="c">   * @static</span>
<span class="c">   * @param {int} id The transaction id.</span>
<span class="c">   * @param {object} callback - User-defined callback object.</span>
<span class="c">   * @param {string} uri Fully qualified path of resource.</span>
<span class="c">   * @return {void}</span>
<span class="c">   */</span>
	<span class="nx">uploadFile</span><span class="o">:</span><span class="k">function</span><span class="o">(</span><span class="nx">id</span><span class="o">,</span> <span class="nx">callback</span><span class="o">,</span> <span class="nx">uri</span><span class="o">,</span> <span class="nx">postData</span><span class="o">){</span>

		<span class="c">// Each iframe has an id prefix of &quot;yuiIO&quot; followed</span>
<span class="c"></span>		<span class="c">// by the unique transaction id.</span>
<span class="c"></span>		<span class="k">var</span> <span class="nx">frameId</span> <span class="o">=</span> <span class="s1">&#39;yuiIO&#39;</span> <span class="o">+</span> <span class="nx">id</span><span class="o">;</span>
		<span class="k">var</span> <span class="nx">uploadEncoding</span> <span class="o">=</span> <span class="s1">&#39;multipart/form-data&#39;</span><span class="o">;</span>
		<span class="k">var</span> <span class="nx">io</span> <span class="o">=</span> <span class="nb">document</span><span class="o">.</span><span class="nx">getElementById</span><span class="o">(</span><span class="nx">frameId</span><span class="o">);</span>

		<span class="c">// Initialize the HTML form properties in case they are</span>
<span class="c"></span>		<span class="c">// not defined in the HTML form.</span>
<span class="c"></span>		<span class="k">this</span><span class="o">.</span><span class="nx">_formNode</span><span class="o">.</span><span class="nx">setAttribute</span><span class="o">(</span><span class="s1">&#39;action&#39;</span><span class="o">,</span> <span class="nx">uri</span><span class="o">);</span>
		<span class="k">this</span><span class="o">.</span><span class="nx">_formNode</span><span class="o">.</span><span class="nx">setAttribute</span><span class="o">(</span><span class="s1">&#39;method&#39;</span><span class="o">,</span> <span class="s1">&#39;POST&#39;</span><span class="o">);</span>
		<span class="k">this</span><span class="o">.</span><span class="nx">_formNode</span><span class="o">.</span><span class="nx">setAttribute</span><span class="o">(</span><span class="s2">&quot;target&quot;</span><span class="o">,</span> <span class="nx">frameId</span><span class="o">);</span>

		<span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_formNode</span><span class="o">.</span><span class="nx">encoding</span><span class="o">){</span>
			<span class="c">// IE does not respect property enctype for HTML forms.</span>
<span class="c"></span>			<span class="c">// Instead it uses the property - &quot;encoding&quot;.</span>
<span class="c"></span>			<span class="k">this</span><span class="o">.</span><span class="nx">_formNode</span><span class="o">.</span><span class="nx">encoding</span> <span class="o">=</span> <span class="nx">uploadEncoding</span><span class="o">;</span>
		<span class="o">}</span>
		<span class="k">else</span><span class="o">{</span>
			<span class="k">this</span><span class="o">.</span><span class="nx">_formNode</span><span class="o">.</span><span class="nx">enctype</span> <span class="o">=</span> <span class="nx">uploadEncoding</span><span class="o">;</span>
		<span class="o">}</span>


		<span class="k">if</span><span class="o">(</span><span class="nx">postData</span><span class="o">){</span>
			<span class="k">var</span> <span class="nx">oElements</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">appendPostData</span><span class="o">(</span><span class="nx">postData</span><span class="o">);</span>
		<span class="o">}</span>

		<span class="k">this</span><span class="o">.</span><span class="nx">_formNode</span><span class="o">.</span><span class="nx">submit</span><span class="o">();</span>

		<span class="k">if</span><span class="o">(</span><span class="nx">oElements</span> <span class="o">&amp;&amp;</span> <span class="nx">oElements</span><span class="o">.</span><span class="nx">length</span> <span class="o">&gt;</span> <span class="m">0</span><span class="o">){</span>
			<span class="k">for</span><span class="o">(</span><span class="k">var</span> <span class="nx">i</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">i</span> <span class="o">&lt;</span> <span class="nx">oElements</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">i</span><span class="o">++){</span>
				<span class="k">this</span><span class="o">.</span><span class="nx">_formNode</span><span class="o">.</span><span class="nx">removeChild</span><span class="o">(</span><span class="nx">oElements</span><span class="o">[</span><span class="nx">i</span><span class="o">]);</span>
			<span class="o">}</span>
		<span class="o">}</span>

		<span class="c">// Reset HTML form status properties.</span>
<span class="c"></span>		<span class="k">this</span><span class="o">.</span><span class="nx">resetFormState</span><span class="o">();</span>

		<span class="c">// Create the upload callback handler that fires when the iframe</span>
<span class="c"></span>		<span class="c">// receives the load event.  Subsequently, the event handler is detached</span>
<span class="c"></span>		<span class="c">// and the iframe removed from the document.</span>
<span class="c"></span>
		<span class="k">var</span> <span class="nx">uploadCallback</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span>
		<span class="o">{</span>
			<span class="k">var</span> <span class="nx">obj</span> <span class="o">=</span> <span class="o">{};</span>
			<span class="nx">obj</span><span class="o">.</span><span class="nx">tId</span> <span class="o">=</span> <span class="nx">id</span><span class="o">;</span>
			<span class="nx">obj</span><span class="o">.</span><span class="nx">argument</span> <span class="o">=</span> <span class="nx">callback</span><span class="o">.</span><span class="nx">argument</span><span class="o">;</span>

			<span class="k">try</span>
			<span class="o">{</span>
				<span class="nx">obj</span><span class="o">.</span><span class="nx">responseText</span> <span class="o">=</span> <span class="nx">io</span><span class="o">.</span><span class="nx">contentWindow</span><span class="o">.</span><span class="nb">document</span><span class="o">.</span><span class="nx">body</span><span class="o">?</span><span class="nx">io</span><span class="o">.</span><span class="nx">contentWindow</span><span class="o">.</span><span class="nb">document</span><span class="o">.</span><span class="nx">body</span><span class="o">.</span><span class="nx">innerHTML</span><span class="o">:</span><span class="kc">null</span><span class="o">;</span>
				<span class="nx">obj</span><span class="o">.</span><span class="nx">responseXML</span> <span class="o">=</span> <span class="nx">io</span><span class="o">.</span><span class="nx">contentWindow</span><span class="o">.</span><span class="nb">document</span><span class="o">.</span><span class="nx">XMLDocument</span><span class="o">?</span><span class="nx">io</span><span class="o">.</span><span class="nx">contentWindow</span><span class="o">.</span><span class="nb">document</span><span class="o">.</span><span class="nx">XMLDocument</span><span class="o">:</span><span class="nx">io</span><span class="o">.</span><span class="nx">contentWindow</span><span class="o">.</span><span class="nb">document</span><span class="o">;</span>
			<span class="o">}</span>
			<span class="k">catch</span><span class="o">(</span><span class="nx">e</span><span class="o">){}</span>

			<span class="k">if</span><span class="o">(</span><span class="nx">callback</span> <span class="o">&amp;&amp;</span> <span class="nx">callback</span><span class="o">.</span><span class="nx">upload</span><span class="o">){</span>
				<span class="k">if</span><span class="o">(!</span><span class="nx">callback</span><span class="o">.</span><span class="nx">scope</span><span class="o">){</span>
					<span class="nx">callback</span><span class="o">.</span><span class="nx">upload</span><span class="o">(</span><span class="nx">obj</span><span class="o">);</span>
					<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">&#39;Upload callback.&#39;</span><span class="o">,</span> <span class="s1">&#39;info&#39;</span><span class="o">,</span> <span class="s1">&#39;Connection&#39;</span><span class="o">);</span>
				<span class="o">}</span>
				<span class="k">else</span><span class="o">{</span>
					<span class="nx">callback</span><span class="o">.</span><span class="nx">upload</span><span class="o">.</span><span class="nx">apply</span><span class="o">(</span><span class="nx">callback</span><span class="o">.</span><span class="nx">scope</span><span class="o">,</span> <span class="o">[</span><span class="nx">obj</span><span class="o">]);</span>
					<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">&#39;Upload callback with scope.&#39;</span><span class="o">,</span> <span class="s1">&#39;info&#39;</span><span class="o">,</span> <span class="s1">&#39;Connection&#39;</span><span class="o">);</span>
				<span class="o">}</span>
			<span class="o">}</span>

			<span class="k">if</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">){</span>
				<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">removeListener</span><span class="o">(</span><span class="nx">io</span><span class="o">,</span> <span class="s2">&quot;load&quot;</span><span class="o">,</span> <span class="nx">uploadCallback</span><span class="o">);</span>
			<span class="o">}</span>
			<span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nb">window</span><span class="o">.</span><span class="nx">detachEvent</span><span class="o">){</span>
				<span class="nx">io</span><span class="o">.</span><span class="nx">detachEvent</span><span class="o">(</span><span class="s1">&#39;onload&#39;</span><span class="o">,</span> <span class="nx">uploadCallback</span><span class="o">);</span>
			<span class="o">}</span>
			<span class="k">else</span><span class="o">{</span>
				<span class="nx">io</span><span class="o">.</span><span class="nx">removeEventListener</span><span class="o">(</span><span class="s1">&#39;load&#39;</span><span class="o">,</span> <span class="nx">uploadCallback</span><span class="o">,</span> <span class="kc">false</span><span class="o">);</span>
			<span class="o">}</span>
			<span class="nx">setTimeout</span><span class="o">(</span>
				<span class="k">function</span><span class="o">(){</span>
					<span class="nb">document</span><span class="o">.</span><span class="nx">body</span><span class="o">.</span><span class="nx">removeChild</span><span class="o">(</span><span class="nx">io</span><span class="o">);</span>
					<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">&#39;File upload iframe destroyed. Id is:&#39;</span> <span class="o">+</span> <span class="nx">frameId</span><span class="o">,</span> <span class="s1">&#39;info&#39;</span><span class="o">,</span> <span class="s1">&#39;Connection&#39;</span><span class="o">);</span>
				<span class="o">},</span> <span class="m">100</span><span class="o">);</span>
		<span class="o">};</span>


		<span class="c">// Bind the onload handler to the iframe to detect the file upload response.</span>
<span class="c"></span>		<span class="k">if</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">){</span>
			<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">addListener</span><span class="o">(</span><span class="nx">io</span><span class="o">,</span> <span class="s2">&quot;load&quot;</span><span class="o">,</span> <span class="nx">uploadCallback</span><span class="o">);</span>
		<span class="o">}</span>
		<span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nb">window</span><span class="o">.</span><span class="nx">attachEvent</span><span class="o">){</span>
			<span class="nx">io</span><span class="o">.</span><span class="nx">attachEvent</span><span class="o">(</span><span class="s1">&#39;onload&#39;</span><span class="o">,</span> <span class="nx">uploadCallback</span><span class="o">);</span>
		<span class="o">}</span>
		<span class="k">else</span><span class="o">{</span>
			<span class="nx">io</span><span class="o">.</span><span class="nx">addEventListener</span><span class="o">(</span><span class="s1">&#39;load&#39;</span><span class="o">,</span> <span class="nx">uploadCallback</span><span class="o">,</span> <span class="kc">false</span><span class="o">);</span>
		<span class="o">}</span>
	<span class="o">},</span>

  <span class="c">/**</span>
<span class="c">   * @description Method to terminate a transaction, if it has not reached readyState 4.</span>
<span class="c">   * @method abort</span>
<span class="c">   * @public</span>
<span class="c">   * @static</span>
<span class="c">   * @param {object} o The connection object returned by asyncRequest.</span>
<span class="c">   * @param {object} callback  User-defined callback object.</span>
<span class="c">   * @param {string} isTimeout boolean to indicate if abort was a timeout.</span>
<span class="c">   * @return {boolean}</span>
<span class="c">   */</span>
	<span class="nx">abort</span><span class="o">:</span><span class="k">function</span><span class="o">(</span><span class="nx">o</span><span class="o">,</span> <span class="nx">callback</span><span class="o">,</span> <span class="nx">isTimeout</span><span class="o">)</span>
	<span class="o">{</span>
		<span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">isCallInProgress</span><span class="o">(</span><span class="nx">o</span><span class="o">)){</span>
			<span class="nx">o</span><span class="o">.</span><span class="nx">conn</span><span class="o">.</span><span class="nx">abort</span><span class="o">();</span>
			<span class="nb">window</span><span class="o">.</span><span class="nx">clearInterval</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_poll</span><span class="o">[</span><span class="nx">o</span><span class="o">.</span><span class="nx">tId</span><span class="o">]);</span>
			<span class="nx">delete</span> <span class="k">this</span><span class="o">.</span><span class="nx">_poll</span><span class="o">[</span><span class="nx">o</span><span class="o">.</span><span class="nx">tId</span><span class="o">];</span>
			<span class="k">if</span><span class="o">(</span><span class="nx">isTimeout</span><span class="o">){</span>
				<span class="nx">delete</span> <span class="k">this</span><span class="o">.</span><span class="nx">_timeOut</span><span class="o">[</span><span class="nx">o</span><span class="o">.</span><span class="nx">tId</span><span class="o">];</span>
			<span class="o">}</span>

			<span class="k">this</span><span class="o">.</span><span class="nx">handleTransactionResponse</span><span class="o">(</span><span class="nx">o</span><span class="o">,</span> <span class="nx">callback</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
			<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">&#39;Transaction &#39;</span> <span class="o">+</span> <span class="nx">o</span><span class="o">.</span><span class="nx">tId</span> <span class="o">+</span> <span class="s1">&#39; aborted.&#39;</span><span class="o">,</span> <span class="s1">&#39;info&#39;</span><span class="o">,</span> <span class="s1">&#39;Connection&#39;</span><span class="o">);</span>

			<span class="k">return</span> <span class="kc">true</span><span class="o">;</span>
		<span class="o">}</span>
		<span class="k">else</span><span class="o">{</span>
			<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">&#39;Transaction &#39;</span> <span class="o">+</span> <span class="nx">o</span><span class="o">.</span><span class="nx">tId</span> <span class="o">+</span> <span class="s1">&#39; abort call failed.&#39;</span><span class="o">,</span> <span class="s1">&#39;warn&#39;</span><span class="o">,</span> <span class="s1">&#39;Connection&#39;</span><span class="o">);</span>
			<span class="k">return</span> <span class="kc">false</span><span class="o">;</span>
		<span class="o">}</span>
	<span class="o">},</span>

  <span class="c">/**</span>
<span class="c">   * Public method to check if the transaction is still being processed.</span>
<span class="c">   *</span>
<span class="c">   * @method isCallInProgress</span>
<span class="c">   * @public</span>
<span class="c">   * @static</span>
<span class="c">   * @param {object} o The connection object returned by asyncRequest</span>
<span class="c">   * @return {boolean}</span>
<span class="c">   */</span>
	<span class="nx">isCallInProgress</span><span class="o">:</span><span class="k">function</span><span class="o">(</span><span class="nx">o</span><span class="o">)</span>
	<span class="o">{</span>
		<span class="c">// if the XHR object assigned to the transaction has not been dereferenced,</span>
<span class="c"></span>		<span class="c">// then check its readyState status.  Otherwise, return false.</span>
<span class="c"></span>		<span class="k">if</span><span class="o">(</span><span class="nx">o</span><span class="o">.</span><span class="nx">conn</span><span class="o">){</span>
			<span class="k">return</span> <span class="nx">o</span><span class="o">.</span><span class="nx">conn</span><span class="o">.</span><span class="nx">readyState</span> <span class="o">!==</span> <span class="m">4</span> <span class="o">&amp;&amp;</span> <span class="nx">o</span><span class="o">.</span><span class="nx">conn</span><span class="o">.</span><span class="nx">readyState</span> <span class="o">!==</span> <span class="m">0</span><span class="o">;</span>
		<span class="o">}</span>
		<span class="k">else</span><span class="o">{</span>
			<span class="c">//The XHR object has been destroyed.</span>
<span class="c"></span>			<span class="k">return</span> <span class="kc">false</span><span class="o">;</span>
		<span class="o">}</span>
	<span class="o">},</span>

  <span class="c">/**</span>
<span class="c">   * @description Dereference the XHR instance and the connection object after the transaction is completed.</span>
<span class="c">   * @method releaseObject</span>
<span class="c">   * @private</span>
<span class="c">   * @static</span>
<span class="c">   * @param {object} o The connection object</span>
<span class="c">   * @return {void}</span>
<span class="c">   */</span>
	<span class="nx">releaseObject</span><span class="o">:</span><span class="k">function</span><span class="o">(</span><span class="nx">o</span><span class="o">)</span>
	<span class="o">{</span>
		<span class="c">//dereference the XHR instance.</span>
<span class="c"></span>		<span class="nx">o</span><span class="o">.</span><span class="nx">conn</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
		<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">&#39;Connection object for transaction &#39;</span> <span class="o">+</span> <span class="nx">o</span><span class="o">.</span><span class="nx">tId</span> <span class="o">+</span> <span class="s1">&#39; destroyed.&#39;</span><span class="o">,</span> <span class="s1">&#39;info&#39;</span><span class="o">,</span> <span class="s1">&#39;Connection&#39;</span><span class="o">);</span>
		<span class="c">//dereference the connection object.</span>
<span class="c"></span>		<span class="nx">o</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
	<span class="o">}</span>
<span class="o">};</span>
</pre></div>
                    </div>
			</div>
		</div>
		<div class="yui-b">
            <div class="nav">

                    <div class="module">
                        <h4>Modules</h4>
                        <ul class="content">

                                <li class=""><a href="module_animation.html">animation</a></li>

                                <li class=""><a href="module_autocomplete.html">autocomplete</a></li>

                                <li class=""><a href="module_button.html">button</a></li>

                                <li class=""><a href="module_calendar.html">calendar</a></li>

                                <li class="selected"><a href="module_connection.html">connection</a></li>

                                <li class=""><a href="module_container.html">container</a></li>

                                <li class=""><a href="module_datasource.html">datasource</a></li>

                                <li class=""><a href="module_datatable.html">datatable</a></li>

                                <li class=""><a href="module_dom.html">dom</a></li>

                                <li class=""><a href="module_dragdrop.html">dragdrop</a></li>

                                <li class=""><a href="module_element.html">element</a></li>

                                <li class=""><a href="module_event.html">event</a></li>

                                <li class=""><a href="module_history.html">history</a></li>

                                <li class=""><a href="module_logger.html">logger</a></li>

                                <li class=""><a href="module_menu.html">menu</a></li>

                                <li class=""><a href="module_slider.html">slider</a></li>

                                <li class=""><a href="module_tabview.html">tabview</a></li>

                                <li class=""><a href="module_treeview.html">treeview</a></li>

                                <li class=""><a href="module_yahoo.html">yahoo</a></li>
                        </ul>
                    </div>

                    <div class="module">
                        <h4>Classes</h4>
                        <ul class="content">
                                <li class=""><a href="YAHOO.util.Connect.html">YAHOO.util.Connect</a></li>
                        </ul>
                    </div>

                    <div class="module">
                        <h4>Files</h4>
                        <ul class="content">        
                                <li class="selected"><a href="connection.js.html">connection.js</a></li>
                        </ul>
                    </div>





            </div>
		</div>
	</div>
	<div id="ft">
        <hr />
        Copyright &copy; 2007 Yahoo! Inc. All rights reserved.
	</div>
</div>
</body>
</html>
